1 | typedef struct _xc_shm_handlers_t xc_shm_handlers_t; |
---|
2 | |
---|
3 | #ifndef XC_SHM_IMPL |
---|
4 | struct _xc_shm_t { |
---|
5 | const xc_shm_handlers_t *handlers; |
---|
6 | }; |
---|
7 | #define XC_SHM_IMPL _xc_shm_t |
---|
8 | #endif |
---|
9 | |
---|
10 | typedef struct XC_SHM_IMPL xc_shm_t; |
---|
11 | typedef size_t xc_shmsize_t; |
---|
12 | |
---|
13 | #include "mem.h" |
---|
14 | |
---|
15 | /* shm */ |
---|
16 | #define XC_SHM_CAN_READONLY(func) int func(xc_shm_t *shm) |
---|
17 | #define XC_SHM_IS_READWRITE(func) int func(xc_shm_t *shm, const void *p) |
---|
18 | #define XC_SHM_IS_READONLY(func) int func(xc_shm_t *shm, const void *p) |
---|
19 | #define XC_SHM_TO_READWRITE(func) void *func(xc_shm_t *shm, void *p) |
---|
20 | #define XC_SHM_TO_READONLY(func) void *func(xc_shm_t *shm, void *p) |
---|
21 | |
---|
22 | #define XC_SHM_INIT(func) xc_shm_t *func(xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2) |
---|
23 | #define XC_SHM_DESTROY(func) void func(xc_shm_t *shm) |
---|
24 | |
---|
25 | #define XC_SHM_MEMINIT(func) xc_mem_t *func(xc_shm_t *shm, xc_memsize_t size) |
---|
26 | #define XC_SHM_MEMDESTROY(func) void func(xc_mem_t *mem) |
---|
27 | |
---|
28 | #define XC_SHM_HANDLERS(name) { \ |
---|
29 | NULL \ |
---|
30 | , xc_##name##_can_readonly \ |
---|
31 | , xc_##name##_is_readwrite \ |
---|
32 | , xc_##name##_is_readonly \ |
---|
33 | , xc_##name##_to_readwrite \ |
---|
34 | , xc_##name##_to_readonly \ |
---|
35 | \ |
---|
36 | , xc_##name##_init \ |
---|
37 | , xc_##name##_destroy \ |
---|
38 | \ |
---|
39 | , xc_##name##_meminit \ |
---|
40 | , xc_##name##_memdestroy \ |
---|
41 | } |
---|
42 | |
---|
43 | struct _xc_shm_handlers_t { |
---|
44 | const xc_mem_handlers_t *memhandlers; |
---|
45 | XC_SHM_CAN_READONLY((*can_readonly)); |
---|
46 | XC_SHM_IS_READWRITE((*is_readwrite)); |
---|
47 | XC_SHM_IS_READONLY((*is_readonly)); |
---|
48 | XC_SHM_TO_READWRITE((*to_readwrite)); |
---|
49 | XC_SHM_TO_READONLY((*to_readonly)); |
---|
50 | XC_SHM_INIT((*init)); |
---|
51 | XC_SHM_DESTROY((*destroy)); |
---|
52 | |
---|
53 | XC_SHM_MEMINIT((*meminit)); |
---|
54 | XC_SHM_MEMDESTROY((*memdestroy)); |
---|
55 | }; |
---|
56 | |
---|
57 | typedef struct _xc_shm_scheme_t xc_shm_scheme_t; |
---|
58 | |
---|
59 | void xc_shm_init_modules(); |
---|
60 | int xc_shm_scheme_register(const char *name, const xc_shm_handlers_t *handlers); |
---|
61 | const xc_shm_handlers_t *xc_shm_scheme_find(const char *name); |
---|
62 | xc_shm_scheme_t *xc_shm_scheme_first(); |
---|
63 | xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme); |
---|
64 | const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme); |
---|
65 | |
---|
66 | xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2); |
---|
67 | void xc_shm_destroy(xc_shm_t *shm); |
---|