Files
2ine-tms34010/native/os2native.h
T
Ryan C. Gordon 26a52988a6 16-bit support!
This gets us everything we need (I hope!) to support 16-bit code in LX
binaries and call into 16-bit OS/2 APIs. This is just enough to call
into VioGetMode() (which isn't otherwise implemented yet) as an example.

If this is ever used Winelib-style to provide an OS/2 API to native Linux
binaries, the 16-bit system APIs are 32-bit clean and C callable, as one
might expect them to be. All the tapdancing is to support existing LX
binaries in the loader and bridge between the 32-bit clean APIs and
existing 16-bit code that expects to call 16-bit APIs.

This was a staggering amount of effort, but yay!

Other fixes and improvements probably leaked into this commit, as a
lot of code got touched and a lot of research and debugging took place.
2016-10-27 01:44:26 -04:00

48 lines
1.2 KiB
C

#ifndef _INCL_OS2NATIVE_H_
#define _INCL_OS2NATIVE_H_
#define _POSIX_C_SOURCE 199309
#define _BSD_SOURCE
#define _GNU_SOURCE
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
#include <errno.h>
#include <sys/mman.h>
#include "os2types.h"
#include "os2errors.h"
#include "../lx_loader.h"
#if 0
#define TRACE_NATIVE(...) do { fprintf(stderr, "2INE TRACE [%lu]: ", (unsigned long) pthread_self()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, ";\n"); } while (0)
#else
#define TRACE_NATIVE(...) do {} while (0)
#endif
OS2EXPORT const LxExport * lxNativeModuleInit(LxLoaderState *lx_state, uint32 *lx_num_exports);
void OS2EXPORT lxNativeModuleDeinit(void);
#define LX_NATIVE_MODULE_DEINIT(deinitcode) \
void lxNativeModuleDeinit(void) { deinitcode; }
#define LX_NATIVE_MODULE_INIT(initcode) \
const LxExport *lxNativeModuleInit(LxLoaderState *lx_state, uint32 *lx_num_exports) { \
initcode; \
static const LxExport lx_native_exports[] = {
#define LX_NATIVE_EXPORT(fn, ord) { ord, #fn, fn, NULL }
#define LX_NATIVE_MODULE_INIT_END() \
}; \
*lx_num_exports = sizeof (lx_native_exports) / sizeof (lx_native_exports[0]); \
return lx_native_exports; \
}
#endif
// end of os2native.h ...