From fba94951bcb3545206edcd5931c6f8c8f55ddadb Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 3 Oct 2024 17:41:54 +0800 Subject: [PATCH] Support newer libzmq. --- src/socket.nobj.lua | 12 ++++++++++++ src/stopwatch.nobj.lua | 4 +++- zmq.nobj.lua | 3 +-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/socket.nobj.lua b/src/socket.nobj.lua index 30798e8..0400edb 100644 --- a/src/socket.nobj.lua +++ b/src/socket.nobj.lua @@ -774,6 +774,9 @@ local tmp_val_len = ffi.new('size_t[1]', 4) -- create helper function for `zmq_send` c_source[[ LUA_NOBJ_API ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_t data_len, int flags) { +#if VERSION_3_2 + return zmq_send(sock, data, data_len, flags); +#else ZMQ_Error err; zmq_msg_t msg; /* initialize message */ @@ -787,6 +790,7 @@ LUA_NOBJ_API ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_ zmq_msg_close(&msg); } return err; +#endif } ]], method "send" { @@ -859,6 +863,14 @@ typedef struct ZMQ_recv_event { const char *err; } ZMQ_recv_event; +#if (ZMQ_VERSION_MAJOR == 4) && (ZMQ_VERSION_MINOR >= 1) +typedef struct zmq_event_t { + int16_t event; + int32_t value; +} zmq_event_t; + +#endif + int monitor_recv_event(ZMQ_Socket *s, zmq_msg_t *msg, int flags, ZMQ_recv_event *ev) { int rc ; diff --git a/src/stopwatch.nobj.lua b/src/stopwatch.nobj.lua index 8deae05..4813760 100644 --- a/src/stopwatch.nobj.lua +++ b/src/stopwatch.nobj.lua @@ -19,8 +19,10 @@ -- THE SOFTWARE. object "ZMQ_StopWatch" { - include "zmq_utils.h", c_source[[ +#if (ZMQ_VERSION_MAJOR <= 4) && (ZMQ_VERSION_MINOR <= 1) +#include "zmq_utils.h" +#endif typedef struct ZMQ_StopWatch ZMQ_StopWatch; ]], constructor "start" { diff --git a/zmq.nobj.lua b/zmq.nobj.lua index b3e17c8..f45f52a 100644 --- a/zmq.nobj.lua +++ b/zmq.nobj.lua @@ -318,9 +318,8 @@ c_function "proxy" { if_defs = "VERSION_3_2", }, -- --- zmq_utils.h +-- utils -- -include "zmq_utils.h", c_function "stopwatch_start" { c_call "!ZMQ_StopWatch *" "zmq_stopwatch_start" {}, },