forked from seifert/ipcqueue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cffi_builder_sysv.py
54 lines (42 loc) · 1.25 KB
/
cffi_builder_sysv.py
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
import os.path
import cffi
ffibuilder = cffi.FFI()
ffibuilder.cdef(
r'''
typedef enum {
SYSVMQ_OK,
SYSVMQ_E,
SYSVMQ_E_VALUE,
SYSVMQ_E_PERMISSIONS,
SYSVMQ_E_RESOURCES,
SYSVMQ_E_DESCRIPTOR,
SYSVMQ_E_SIGNAL,
SYSVMQ_E_SIZE,
SYSVMQ_E_FULL,
SYSVMQ_E_EMPTY,
} SysVMqResult;
typedef struct {
size_t size;
size_t max_bytes;
} SysVMqAttr;
SysVMqResult sysvmq_open(const unsigned int key, int * const mq);
SysVMqResult sysvmq_close(const int mq);
SysVMqResult sysvmq_put(const int mq, const char * const msg,
const size_t msg_size, const long msg_type,
const double timeout);
SysVMqResult sysvmq_get(const int mq, char * const buffer,
size_t * const size, const long msg_type,
const double timeout);
SysVMqResult sysvmq_get_attr(const int mq, SysVMqAttr * const attr);
SysVMqResult sysvmq_set_max_bytes(const int mq, const size_t max_bytes);
'''
)
ffibuilder.set_source(
'ipcqueue._sysvmq',
'#include "ipcqueue/sysvmq.h"',
sources=['ipcqueue/sysvmq.c'],
extra_compile_args=[
'-I{}'.format(os.path.abspath(os.path.dirname(__file__))),
],
libraries=[]
)