From 33419425eb3588c06fbc2d78bcc6758a0cf17712 Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Fri, 21 Aug 2015 16:12:22 -0700 Subject: [PATCH] Problem: Private/internal macros defined in public header. Solution: Move the macros to a private header. --- include/zmq.h | 13 ------------- src/address.cpp | 1 + src/client.cpp | 1 + src/ctx.cpp | 1 + src/dealer.cpp | 1 + src/epoll.cpp | 1 + src/io_thread.cpp | 1 + src/kqueue.cpp | 1 + src/macros.hpp | 12 ++++++++++++ src/msg.cpp | 1 + src/mtrie.cpp | 1 + src/pair.cpp | 1 + src/pgm_receiver.cpp | 1 + src/pipe.cpp | 1 + src/pull.cpp | 1 + src/push.cpp | 1 + src/reaper.cpp | 1 + src/router.cpp | 1 + src/server.cpp | 1 + src/session_base.cpp | 1 + src/socket_base.cpp | 1 + src/socks_connecter.cpp | 1 + src/stream.cpp | 1 + src/stream_engine.cpp | 1 + src/tcp.cpp | 1 + src/tcp_address.cpp | 1 + src/tcp_connecter.cpp | 1 + src/trie.cpp | 1 + src/xsub.cpp | 1 + src/zmq.cpp | 1 + src/zmq_utils.cpp | 1 + 31 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 src/macros.hpp diff --git a/include/zmq.h b/include/zmq.h index cc70a72a..f797b4c6 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -511,19 +511,6 @@ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg); ZMQ_EXPORT void zmq_threadclose (void* thread); -/******************************************************************************/ -/* 0MQ Internal Use */ -/******************************************************************************/ - -#define LIBZMQ_UNUSED(object) (void)object -#define LIBZMQ_DELETE(p_object) {\ - delete p_object; \ - p_object = 0; \ -} - - -/******************************************************************************/ - #undef ZMQ_EXPORT #ifdef __cplusplus diff --git a/src/address.cpp b/src/address.cpp index 3db14f0d..694d54d1 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "platform.hpp" #include "address.hpp" #include "err.hpp" diff --git a/src/client.cpp b/src/client.cpp index e8885cca..7ed01f88 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "client.hpp" #include "err.hpp" #include "msg.hpp" diff --git a/src/ctx.cpp b/src/ctx.cpp index d6240a35..0b28ed61 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "platform.hpp" #ifdef ZMQ_HAVE_WINDOWS #include "windows.hpp" diff --git a/src/dealer.cpp b/src/dealer.cpp index 301478e7..87c2721f 100644 --- a/src/dealer.cpp +++ b/src/dealer.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "dealer.hpp" #include "err.hpp" #include "msg.hpp" diff --git a/src/epoll.cpp b/src/epoll.cpp index a57c8b99..fa4bc891 100644 --- a/src/epoll.cpp +++ b/src/epoll.cpp @@ -37,6 +37,7 @@ #include #include +#include "macros.hpp" #include "epoll.hpp" #include "err.hpp" #include "config.hpp" diff --git a/src/io_thread.cpp b/src/io_thread.cpp index f07a4982..9669ee36 100644 --- a/src/io_thread.cpp +++ b/src/io_thread.cpp @@ -29,6 +29,7 @@ #include +#include "macros.hpp" #include "io_thread.hpp" #include "platform.hpp" #include "err.hpp" diff --git a/src/kqueue.cpp b/src/kqueue.cpp index 16aed56d..97b270fe 100644 --- a/src/kqueue.cpp +++ b/src/kqueue.cpp @@ -38,6 +38,7 @@ #include #include +#include "macros.hpp" #include "kqueue.hpp" #include "err.hpp" #include "config.hpp" diff --git a/src/macros.hpp b/src/macros.hpp new file mode 100644 index 00000000..3bb6267b --- /dev/null +++ b/src/macros.hpp @@ -0,0 +1,12 @@ + +/******************************************************************************/ +/* 0MQ Internal Use */ +/******************************************************************************/ + +#define LIBZMQ_UNUSED(object) (void)object +#define LIBZMQ_DELETE(p_object) {\ + delete p_object; \ + p_object = 0; \ +} + +/******************************************************************************/ diff --git a/src/msg.cpp b/src/msg.cpp index c3ddff59..47fe7a25 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "msg.hpp" #include "../include/zmq.h" diff --git a/src/mtrie.cpp b/src/mtrie.cpp index e3093df6..81adc8b1 100644 --- a/src/mtrie.cpp +++ b/src/mtrie.cpp @@ -32,6 +32,7 @@ #include #include +#include "macros.hpp" #include "platform.hpp" #if defined ZMQ_HAVE_WINDOWS #include "windows.hpp" diff --git a/src/pair.cpp b/src/pair.cpp index e3dd786a..18e5cb66 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "pair.hpp" #include "err.hpp" #include "pipe.hpp" diff --git a/src/pgm_receiver.cpp b/src/pgm_receiver.cpp index 45213ca8..020cdbcd 100644 --- a/src/pgm_receiver.cpp +++ b/src/pgm_receiver.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "platform.hpp" #if defined ZMQ_HAVE_OPENPGM diff --git a/src/pipe.cpp b/src/pipe.cpp index 182011b9..2634261d 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -30,6 +30,7 @@ #include #include +#include "macros.hpp" #include "pipe.hpp" #include "err.hpp" diff --git a/src/pull.cpp b/src/pull.cpp index 3153f852..a958b4c9 100644 --- a/src/pull.cpp +++ b/src/pull.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "pull.hpp" #include "err.hpp" #include "msg.hpp" diff --git a/src/push.cpp b/src/push.cpp index fdbca661..31b1b0f5 100644 --- a/src/push.cpp +++ b/src/push.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "push.hpp" #include "pipe.hpp" #include "err.hpp" diff --git a/src/reaper.cpp b/src/reaper.cpp index 34789ddd..2de9dbc1 100644 --- a/src/reaper.cpp +++ b/src/reaper.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "reaper.hpp" #include "socket_base.hpp" #include "err.hpp" diff --git a/src/router.cpp b/src/router.cpp index 47a774ec..cee273bb 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "router.hpp" #include "pipe.hpp" #include "wire.hpp" diff --git a/src/server.cpp b/src/server.cpp index 37796897..9552482c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "server.hpp" #include "pipe.hpp" #include "wire.hpp" diff --git a/src/session_base.cpp b/src/session_base.cpp index 461c9cab..3c1b9107 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "session_base.hpp" #include "i_engine.hpp" #include "err.hpp" diff --git a/src/socket_base.cpp b/src/socket_base.cpp index e29a6d2a..0a9819d7 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -31,6 +31,7 @@ #include #include +#include "macros.hpp" #include "platform.hpp" #if defined ZMQ_HAVE_WINDOWS diff --git a/src/socks_connecter.cpp b/src/socks_connecter.cpp index e621e85a..fdfb5db5 100644 --- a/src/socks_connecter.cpp +++ b/src/socks_connecter.cpp @@ -30,6 +30,7 @@ #include #include +#include "macros.hpp" #include "socks_connecter.hpp" #include "stream_engine.hpp" #include "platform.hpp" diff --git a/src/stream.cpp b/src/stream.cpp index 6a486b89..a5310523 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "stream.hpp" #include "pipe.hpp" #include "wire.hpp" diff --git a/src/stream_engine.cpp b/src/stream_engine.cpp index 5cd51066..44814802 100644 --- a/src/stream_engine.cpp +++ b/src/stream_engine.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "platform.hpp" #if defined ZMQ_HAVE_WINDOWS #include "windows.hpp" diff --git a/src/tcp.cpp b/src/tcp.cpp index 76423bce..80e1721f 100644 --- a/src/tcp.cpp +++ b/src/tcp.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "ip.hpp" #include "tcp.hpp" #include "err.hpp" diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index 21ee9479..e2b4e800 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -30,6 +30,7 @@ #include #include +#include "macros.hpp" #include "tcp_address.hpp" #include "platform.hpp" #include "stdint.hpp" diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index a9d0631e..aeef2c80 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -30,6 +30,7 @@ #include #include +#include "macros.hpp" #include "tcp_connecter.hpp" #include "stream_engine.hpp" #include "io_thread.hpp" diff --git a/src/trie.cpp b/src/trie.cpp index 87d80346..06bbbfa1 100644 --- a/src/trie.cpp +++ b/src/trie.cpp @@ -32,6 +32,7 @@ #include #include +#include "macros.hpp" #include "platform.hpp" #if defined ZMQ_HAVE_WINDOWS #include "windows.hpp" diff --git a/src/xsub.cpp b/src/xsub.cpp index 2614f979..61c2a329 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -29,6 +29,7 @@ #include +#include "macros.hpp" #include "xsub.hpp" #include "err.hpp" diff --git a/src/zmq.cpp b/src/zmq.cpp index ca514a6b..1a7da781 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -28,6 +28,7 @@ */ #define ZMQ_TYPE_UNSAFE +#include "macros.hpp" #include "poller.hpp" // On AIX platform, poll.h has to be included first to get consistent diff --git a/src/zmq_utils.cpp b/src/zmq_utils.cpp index 56114045..484e24f3 100644 --- a/src/zmq_utils.cpp +++ b/src/zmq_utils.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . */ +#include "macros.hpp" #include "platform.hpp" #include "clock.hpp"