Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.48 KB

os2native.h

File metadata and controls

54 lines (42 loc) · 1.48 KB
 
Oct 27, 2016
Oct 27, 2016
1
2
#ifndef _INCL_OS2NATIVE_H_
#define _INCL_OS2NATIVE_H_
Oct 27, 2016
Oct 27, 2016
4
5
6
#define _POSIX_C_SOURCE 199309
#define _BSD_SOURCE
#define _GNU_SOURCE
7
8
#include <stdint.h>
#include <stdlib.h>
Oct 27, 2016
Oct 27, 2016
9
#include <string.h>
Oct 2, 2016
Oct 2, 2016
10
#include <assert.h>
Oct 14, 2016
Oct 14, 2016
11
#include <pthread.h>
Oct 6, 2016
Oct 6, 2016
12
#include <errno.h>
Oct 27, 2016
Oct 27, 2016
13
#include <sys/mman.h>
14
15
16
17
18
#include "os2types.h"
#include "os2errors.h"
#include "../lx_loader.h"
Oct 27, 2016
Oct 27, 2016
19
20
21
22
23
// note that this is defined in _every_ module that includes this file!
static LxLoaderState *GLoaderState = NULL;
#if 1
#define TRACE_NATIVE(...) do { if (GLoaderState->trace_native) { fprintf(stderr, "2INE TRACE [%lu]: ", (unsigned long) pthread_self()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, ";\n"); } } while (0)
24
25
26
27
#else
#define TRACE_NATIVE(...) do {} while (0)
#endif
Oct 2, 2016
Oct 2, 2016
28
29
30
31
OS2EXPORT const LxExport * lxNativeModuleInit(LxLoaderState *lx_state, uint32 *lx_num_exports);
void OS2EXPORT lxNativeModuleDeinit(void);
#define LX_NATIVE_MODULE_DEINIT(deinitcode) \
Oct 27, 2016
Oct 27, 2016
32
33
34
35
void lxNativeModuleDeinit(void) { \
deinitcode; \
GLoaderState = NULL; \
}
Oct 2, 2016
Oct 2, 2016
36
37
38
#define LX_NATIVE_MODULE_INIT(initcode) \
const LxExport *lxNativeModuleInit(LxLoaderState *lx_state, uint32 *lx_num_exports) { \
Oct 27, 2016
Oct 27, 2016
39
GLoaderState = lx_state; \
Oct 2, 2016
Oct 2, 2016
40
41
42
initcode; \
static const LxExport lx_native_exports[] = {
Oct 27, 2016
Oct 27, 2016
43
#define LX_NATIVE_EXPORT(fn, ord) { ord, #fn, fn, NULL }
Oct 2, 2016
Oct 2, 2016
44
45
46
47
48
49
#define LX_NATIVE_MODULE_INIT_END() \
}; \
*lx_num_exports = sizeof (lx_native_exports) / sizeof (lx_native_exports[0]); \
return lx_native_exports; \
}
50
51
52
#endif
Oct 27, 2016
Oct 27, 2016
53
// end of os2native.h ...