diff options
author | Michael Dickens <michael.dickens@ettus.com> | 2019-05-26 14:36:53 -0400 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-06-15 17:20:15 -0700 |
commit | 82251fad9cf3314124d4a91e97a35f6b0f78e5bb (patch) | |
tree | 430fc2e0cd40b3d6d27def0293ea759bb0029e6b | |
parent | 6996d1b7ee20fb7611068906bb64886eb5b514ef (diff) |
zeromq: fixes to allow building using CPPZMQ 4.3.1 as well as prior
CPPZMQ deprecated some prototypes of "recv" and "send" in some version prior to 4.3.1. The "recv" one will be removed in 4.3.1 and thus will generate an error since no valid prototype exists in the way "recv" is currently being call. This fix updates our usage of both calls to work with the "new" and "old" ways, depending on the CPPZMQ version. Move the CPPZMQ header inclusion and a macro determine which version to use into a common local header.
-rw-r--r-- | gr-zeromq/lib/base_impl.cc | 10 | ||||
-rw-r--r-- | gr-zeromq/lib/base_impl.h | 5 | ||||
-rw-r--r-- | gr-zeromq/lib/pull_msg_source_impl.cc | 6 | ||||
-rw-r--r-- | gr-zeromq/lib/pull_msg_source_impl.h | 4 | ||||
-rw-r--r-- | gr-zeromq/lib/rep_msg_sink_impl.cc | 6 | ||||
-rw-r--r-- | gr-zeromq/lib/rep_msg_sink_impl.h | 4 | ||||
-rw-r--r-- | gr-zeromq/lib/rep_sink_impl.cc | 6 | ||||
-rw-r--r-- | gr-zeromq/lib/rep_sink_impl.h | 4 | ||||
-rw-r--r-- | gr-zeromq/lib/req_msg_source_impl.cc | 10 | ||||
-rw-r--r-- | gr-zeromq/lib/req_msg_source_impl.h | 4 | ||||
-rw-r--r-- | gr-zeromq/lib/sub_msg_source_impl.cc | 7 | ||||
-rw-r--r-- | gr-zeromq/lib/sub_msg_source_impl.h | 4 | ||||
-rw-r--r-- | gr-zeromq/lib/zmq_common_impl.h | 34 |
13 files changed, 83 insertions, 21 deletions
diff --git a/gr-zeromq/lib/base_impl.cc b/gr-zeromq/lib/base_impl.cc index 0465ec3abb..662f7b1596 100644 --- a/gr-zeromq/lib/base_impl.cc +++ b/gr-zeromq/lib/base_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2016 Free Software Foundation, Inc. + * Copyright 2016,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -105,7 +105,11 @@ namespace gr { } /* Send */ +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->send(msg, zmq::send_flags::none); +#else d_socket->send(msg); +#endif /* Report back */ return in_nitems; @@ -186,7 +190,11 @@ namespace gr { d_consumed_bytes = 0; /* Get the message */ +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(d_msg); +#else d_socket->recv(&d_msg); +#endif /* Parse header from the first (or only) message of a multi-part message */ if (d_pass_tags && !more) diff --git a/gr-zeromq/lib/base_impl.h b/gr-zeromq/lib/base_impl.h index e09e652768..68f0fa2ea5 100644 --- a/gr-zeromq/lib/base_impl.h +++ b/gr-zeromq/lib/base_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2016 Free Software Foundation, Inc. + * Copyright 2016,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -23,9 +23,8 @@ #ifndef INCLUDED_ZEROMQ_BASE_IMPL_H #define INCLUDED_ZEROMQ_BASE_IMPL_H -#include <zmq.hpp> - #include <gnuradio/sync_block.h> +#include "zmq_common_impl.h" namespace gr { namespace zeromq { diff --git a/gr-zeromq/lib/pull_msg_source_impl.cc b/gr-zeromq/lib/pull_msg_source_impl.cc index 7e2efff570..48ad2bd5b1 100644 --- a/gr-zeromq/lib/pull_msg_source_impl.cc +++ b/gr-zeromq/lib/pull_msg_source_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -97,7 +97,11 @@ namespace gr { // Receive data zmq::message_t msg; +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(msg); +#else d_socket->recv(&msg); +#endif std::string buf(static_cast<char*>(msg.data()), msg.size()); std::stringbuf sb(buf); diff --git a/gr-zeromq/lib/pull_msg_source_impl.h b/gr-zeromq/lib/pull_msg_source_impl.h index 25cd2dee31..db01e8d038 100644 --- a/gr-zeromq/lib/pull_msg_source_impl.h +++ b/gr-zeromq/lib/pull_msg_source_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -24,7 +24,7 @@ #define INCLUDED_ZEROMQ_PULL_MSG_SOURCE_IMPL_H #include <gnuradio/zeromq/pull_msg_source.h> -#include <zmq.hpp> +#include "zmq_common_impl.h" namespace gr { namespace zeromq { diff --git a/gr-zeromq/lib/rep_msg_sink_impl.cc b/gr-zeromq/lib/rep_msg_sink_impl.cc index 3a1086e2c1..1a4696aee5 100644 --- a/gr-zeromq/lib/rep_msg_sink_impl.cc +++ b/gr-zeromq/lib/rep_msg_sink_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -99,7 +99,11 @@ namespace gr { // receive data request zmq::message_t request; +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(request); +#else d_socket->recv(&request); +#endif int req_output_items = *(static_cast<int*>(request.data())); if(req_output_items != 1) diff --git a/gr-zeromq/lib/rep_msg_sink_impl.h b/gr-zeromq/lib/rep_msg_sink_impl.h index 6f788690c9..61895e6c32 100644 --- a/gr-zeromq/lib/rep_msg_sink_impl.h +++ b/gr-zeromq/lib/rep_msg_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -24,7 +24,7 @@ #define INCLUDED_ZEROMQ_REP_MSG_SINK_IMPL_H #include <gnuradio/zeromq/rep_msg_sink.h> -#include <zmq.hpp> +#include "zmq_common_impl.h" namespace gr { namespace zeromq { diff --git a/gr-zeromq/lib/rep_sink_impl.cc b/gr-zeromq/lib/rep_sink_impl.cc index d502ea4780..f402310cfc 100644 --- a/gr-zeromq/lib/rep_sink_impl.cc +++ b/gr-zeromq/lib/rep_sink_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -71,7 +71,11 @@ namespace gr { /* Get and parse the request */ zmq::message_t request; +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(request); +#else d_socket->recv(&request); +#endif int nitems_send = noutput_items - done; if (request.size() >= sizeof(uint32_t)) diff --git a/gr-zeromq/lib/rep_sink_impl.h b/gr-zeromq/lib/rep_sink_impl.h index b9451cfeaf..cfd1c09637 100644 --- a/gr-zeromq/lib/rep_sink_impl.h +++ b/gr-zeromq/lib/rep_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -24,8 +24,6 @@ #define INCLUDED_ZEROMQ_REP_SINK_IMPL_H #include <gnuradio/zeromq/rep_sink.h> -#include <zmq.hpp> - #include "base_impl.h" namespace gr { diff --git a/gr-zeromq/lib/req_msg_source_impl.cc b/gr-zeromq/lib/req_msg_source_impl.cc index 4cfd03f686..6c80a77f27 100644 --- a/gr-zeromq/lib/req_msg_source_impl.cc +++ b/gr-zeromq/lib/req_msg_source_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -99,7 +99,11 @@ namespace gr { int nmsg = 1; zmq::message_t request(sizeof(int)); memcpy((void *) request.data (), &nmsg, sizeof(int)); +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->send(request, zmq::send_flags::none); +#else d_socket->send(request); +#endif } zmq::pollitem_t items[] = { { static_cast<void *>(*d_socket), 0, ZMQ_POLLIN, 0 } }; @@ -109,7 +113,11 @@ namespace gr { if (items[0].revents & ZMQ_POLLIN) { // Receive data zmq::message_t msg; +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(msg); +#else d_socket->recv(&msg); +#endif std::string buf(static_cast<char*>(msg.data()), msg.size()); std::stringbuf sb(buf); diff --git a/gr-zeromq/lib/req_msg_source_impl.h b/gr-zeromq/lib/req_msg_source_impl.h index c9e81efc5d..7fb3e74e70 100644 --- a/gr-zeromq/lib/req_msg_source_impl.h +++ b/gr-zeromq/lib/req_msg_source_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -24,7 +24,7 @@ #define INCLUDED_ZEROMQ_REQ_MSG_SOURCE_IMPL_H #include <gnuradio/zeromq/req_msg_source.h> -#include <zmq.hpp> +#include "zmq_common_impl.h" namespace gr { namespace zeromq { diff --git a/gr-zeromq/lib/sub_msg_source_impl.cc b/gr-zeromq/lib/sub_msg_source_impl.cc index 8ed2420293..3a08499b12 100644 --- a/gr-zeromq/lib/sub_msg_source_impl.cc +++ b/gr-zeromq/lib/sub_msg_source_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -96,8 +96,11 @@ namespace gr { // Receive data zmq::message_t msg; +#if USE_NEW_CPPZMQ_SEND_RECV + d_socket->recv(msg); +#else d_socket->recv(&msg); - +#endif std::string buf(static_cast<char*>(msg.data()), msg.size()); std::stringbuf sb(buf); pmt::pmt_t m = pmt::deserialize(sb); diff --git a/gr-zeromq/lib/sub_msg_source_impl.h b/gr-zeromq/lib/sub_msg_source_impl.h index f0367c6c70..4ffce4ba5f 100644 --- a/gr-zeromq/lib/sub_msg_source_impl.h +++ b/gr-zeromq/lib/sub_msg_source_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2013,2014 Free Software Foundation, Inc. + * Copyright 2013,2014,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio. * @@ -24,7 +24,7 @@ #define INCLUDED_ZEROMQ_SUB_MSG_SOURCE_IMPL_H #include <gnuradio/zeromq/sub_msg_source.h> -#include "zmq.hpp" +#include "zmq_common_impl.h" namespace gr { namespace zeromq { diff --git a/gr-zeromq/lib/zmq_common_impl.h b/gr-zeromq/lib/zmq_common_impl.h new file mode 100644 index 0000000000..e73a3a17d3 --- /dev/null +++ b/gr-zeromq/lib/zmq_common_impl.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Free Software Foundation, Inc. + * + * This file is part of GNU Radio. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_ZEROMQ_ZMQ_COMMON_IMPL_H +#define INCLUDED_ZEROMQ_ZMQ_COMMON_IMPL_H + +#include <zmq.hpp> + +#if defined (CPPZMQ_VERSION) && defined (ZMQ_MAKE_VERSION) && CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 1) +#define USE_NEW_CPPZMQ_SEND_RECV 1 +#else +#define USE_NEW_CPPZMQ_SEND_RECV 0 +#endif + +#endif /* INCLUDED_ZEROMQ_ZMQ_COMMON_IMPL_H */ |