-
Notifications
You must be signed in to change notification settings - Fork 20
/
iocaml_zmq_stubs.c
63 lines (52 loc) · 1.13 KB
/
iocaml_zmq_stubs.c
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
#include <zmq.h>
#include <caml/mlvalues.h>
#include <caml/threads.h>
/*
* release then re-acquire ocaml runtime system during
* zmq_msg_send/recv so threads continue to run.
*
*/
int iocaml_zmq_msg_send(zmq_msg_t *msg, void *socket, int flags) {
int ret;
caml_release_runtime_system();
ret = zmq_msg_send(msg, socket, flags);
caml_acquire_runtime_system();
return ret;
}
int iocaml_zmq_msg_recv(zmq_msg_t *msg, void *socket, int flags) {
int ret;
caml_release_runtime_system();
ret = zmq_msg_recv(msg, socket, flags);
caml_acquire_runtime_system();
return ret;
}
/*
* Constants
*
*/
int iocaml_sizeof_zmq_msg_t(void) { return (int) sizeof(zmq_msg_t); }
#define PARAM(x) int iocaml_##x (void) { return x; }
PARAM(ZMQ_NOBLOCK)
PARAM(ZMQ_SNDMORE)
PARAM(ZMQ_RCVMORE)
PARAM(ZMQ_LINGER)
PARAM(ZMQ_SUBSCRIBE)
PARAM(ZMQ_IDENTITY)
PARAM(ZMQ_FD)
PARAM(ZMQ_POLLIN)
PARAM(ZMQ_POLLOUT)
PARAM(ZMQ_POLLERR)
PARAM(ZMQ_EVENTS)
PARAM(ZMQ_PAIR)
PARAM(ZMQ_PUB)
PARAM(ZMQ_SUB)
PARAM(ZMQ_REQ)
PARAM(ZMQ_REP)
PARAM(ZMQ_DEALER)
PARAM(ZMQ_ROUTER)
PARAM(ZMQ_PULL)
PARAM(ZMQ_PUSH)
PARAM(ZMQ_XPUB)
PARAM(ZMQ_XSUB)
PARAM(EAGAIN)
PARAM(EINTR)