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