source: trunk/xc_shm.h @ 305

Last change on this file since 305 was 305, checked in by moo, 7 years ago

TRACE() instead of ifdef/fprintf

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