source: branches/1.2/xc_shm.h @ 394

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

merged [393] from trunk: svn:eol-style

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1typedef struct _xc_shm_handlers_t xc_shm_handlers_t;
2
3#ifndef XC_SHM_IMPL
4struct _xc_shm_t {
5    const xc_shm_handlers_t *handlers;
6};
7#define XC_SHM_IMPL _xc_shm_t
8#endif
9
10typedef struct XC_SHM_IMPL xc_shm_t;
11typedef 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
43struct _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
57typedef struct _xc_shm_scheme_t xc_shm_scheme_t;
58
59void xc_shm_init_modules();
60int xc_shm_scheme_register(const char *name, const xc_shm_handlers_t *handlers);
61const xc_shm_handlers_t *xc_shm_scheme_find(const char *name);
62xc_shm_scheme_t *xc_shm_scheme_first();
63xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme);
64const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme);
65
66xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2);
67void xc_shm_destroy(xc_shm_t *shm);
Note: See TracBrowser for help on using the repository browser.