source: trunk/xc_shm.h @ 381

Last change on this file since 381 was 381, checked in by moo, 8 years ago

merged [380] from 1.2: make life easier for debugging

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