File: xc_shm.h

package info (click to toggle)
xcache 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,724 kB
  • sloc: ansic: 8,175; php: 4,557; awk: 285; sh: 135; makefile: 75
file content (70 lines) | stat: -rwxr-xr-x 2,289 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef XC_SHM_H
#define XC_SHM_H
typedef struct _xc_shm_handlers_t xc_shm_handlers_t;

#ifndef XC_SHM_IMPL
struct _xc_shm_t {
	const xc_shm_handlers_t *handlers;
};
#define XC_SHM_IMPL _xc_shm_t
#endif

typedef struct XC_SHM_IMPL xc_shm_t;
typedef size_t xc_shmsize_t;

#include "mem.h"

/* shm */
#define XC_SHM_CAN_READONLY(func) int   func(xc_shm_t *shm)
#define XC_SHM_IS_READWRITE(func) int   func(xc_shm_t *shm, const void *p)
#define XC_SHM_IS_READONLY(func)  int   func(xc_shm_t *shm, const void *p)
#define XC_SHM_TO_READWRITE(func) void *func(xc_shm_t *shm, void *p)
#define XC_SHM_TO_READONLY(func)  void *func(xc_shm_t *shm, void *p)

#define XC_SHM_INIT(func)         xc_shm_t *func(xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2)
#define XC_SHM_DESTROY(func)      void func(xc_shm_t *shm)

#define XC_SHM_MEMINIT(func)      xc_mem_t *func(xc_shm_t *shm, xc_memsize_t size)
#define XC_SHM_MEMDESTROY(func)   void func(xc_mem_t *mem)

#define XC_SHM_HANDLERS(name)    { \
	NULL                           \
	, xc_##name##_can_readonly     \
	, xc_##name##_is_readwrite     \
	, xc_##name##_is_readonly      \
	, xc_##name##_to_readwrite     \
	, xc_##name##_to_readonly      \
\
	, xc_##name##_init             \
	, xc_##name##_destroy          \
\
	, xc_##name##_meminit          \
	, xc_##name##_memdestroy       \
}

struct _xc_shm_handlers_t {
	const xc_mem_handlers_t *memhandlers;
	XC_SHM_CAN_READONLY((*can_readonly));
	XC_SHM_IS_READWRITE((*is_readwrite));
	XC_SHM_IS_READONLY((*is_readonly));
	XC_SHM_TO_READWRITE((*to_readwrite));
	XC_SHM_TO_READONLY((*to_readonly));
	XC_SHM_INIT((*init));
	XC_SHM_DESTROY((*destroy));

	XC_SHM_MEMINIT((*meminit));
	XC_SHM_MEMDESTROY((*memdestroy));
};

typedef struct _xc_shm_scheme_t xc_shm_scheme_t;

void xc_shm_init_modules();
int xc_shm_scheme_register(const char *name, const xc_shm_handlers_t *handlers);
const xc_shm_handlers_t *xc_shm_scheme_find(const char *name);
xc_shm_scheme_t *xc_shm_scheme_first();
xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme);
const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme);

xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2);
void xc_shm_destroy(xc_shm_t *shm);
#endif