mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-03 12:58:05 +01:00
Problem: size of zmq_msg_t is not known to FFI wrappers
Solution: add a ZMQ_MSG_T_SIZE context read-only option so that wrappers can call zmq_ctx_get (ctx, ZMQ_MSG_T_SIZE) to get the size at runtime.
This commit is contained in:
parent
3db69212b7
commit
670bec56d8
@ -206,6 +206,9 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
|
||||
#define ZMQ_THREAD_PRIORITY 3
|
||||
#define ZMQ_THREAD_SCHED_POLICY 4
|
||||
#define ZMQ_MAX_MSGSZ 5
|
||||
// All options after this is for version 4.3 and still *draft*
|
||||
// Subject to arbitrary change without notice
|
||||
#define ZMQ_MSG_T_SIZE 6
|
||||
|
||||
/* Default for new contexts */
|
||||
#define ZMQ_IO_THREADS_DFLT 1
|
||||
|
@ -301,6 +301,9 @@ int zmq::ctx_t::get (int option_)
|
||||
else
|
||||
if (option_ == ZMQ_MAX_MSGSZ)
|
||||
rc = max_msgsz;
|
||||
else
|
||||
if (option_ == ZMQ_MSG_T_SIZE)
|
||||
rc = sizeof (zmq_msg_t);
|
||||
else {
|
||||
errno = EINVAL;
|
||||
rc = -1;
|
||||
|
@ -48,6 +48,7 @@ int main (void)
|
||||
#endif
|
||||
assert (zmq_ctx_get (ctx, ZMQ_IO_THREADS) == ZMQ_IO_THREADS_DFLT);
|
||||
assert (zmq_ctx_get (ctx, ZMQ_IPV6) == 0);
|
||||
assert (zmq_ctx_get (ctx, ZMQ_MSG_T_SIZE) == sizeof (zmq_msg_t));
|
||||
|
||||
rc = zmq_ctx_set (ctx, ZMQ_IPV6, true);
|
||||
assert (zmq_ctx_get (ctx, ZMQ_IPV6) == 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user