source: trunk/xc_shm.h @ 163

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

show available shm scheme in moduleinfo

File size: 2.1 KB
RevLine 
[1]1typedef struct _xc_shm_t xc_shm_t;
[11]2typedef size_t xc_shmsize_t;
[1]3
[148]4#include "mem.h"
[1]5
[148]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)
[1]12
[148]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
34typedef 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
50struct _xc_shm_t {
51    const xc_shm_handlers_t *handlers;
52};
53#endif
[163]54typedef struct _xc_shm_scheme_t xc_shm_scheme_t;
[148]55
56void xc_shm_init_modules();
57int xc_shm_scheme_register(const char *name, const xc_shm_handlers_t *handlers);
58const xc_shm_handlers_t *xc_shm_scheme_find(const char *name);
[163]59xc_shm_scheme_t *xc_shm_scheme_first();
60xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme);
61const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme);
[148]62
63xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2);
[1]64void xc_shm_destroy(xc_shm_t *shm);
Note: See TracBrowser for help on using the repository browser.