summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-07-24 18:13:29 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-07-24 18:13:29 +0200
commitf716b571baf59c1b622c7666bb8bf2905126a3d4 (patch)
treee674579a8fe13664ef5254cfc1c591c6be870426 /src
parent0e71b111f4c413e235978698e8a281acab3bb06e (diff)
Only one polling mechanism is compiled
Till now wrappers for all the polling mechanisms available on the given platform were compiled, although only one of them was used. This patch compiles just the used one. This can make libzmq binary more concise. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/devpoll.cpp5
-rw-r--r--src/devpoll.hpp8
-rw-r--r--src/epoll.cpp5
-rw-r--r--src/epoll.hpp8
-rw-r--r--src/kqueue.cpp8
-rw-r--r--src/kqueue.hpp9
-rw-r--r--src/poll.cpp9
-rw-r--r--src/poll.hpp12
-rw-r--r--src/poller.hpp62
-rw-r--r--src/select.cpp5
-rw-r--r--src/select.hpp7
11 files changed, 74 insertions, 64 deletions
diff --git a/src/devpoll.cpp b/src/devpoll.cpp
index 25763c6..c4b3c54 100644
--- a/src/devpoll.cpp
+++ b/src/devpoll.cpp
@@ -18,9 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_HPUX
+#include "devpoll.hpp"
+#if defined ZMQ_USE_DEVPOLL
#include <sys/devpoll.h>
#include <sys/time.h>
diff --git a/src/devpoll.hpp b/src/devpoll.hpp
index 2eaaeb2..a668e9a 100644
--- a/src/devpoll.hpp
+++ b/src/devpoll.hpp
@@ -21,9 +21,9 @@
#ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__
#define __ZMQ_DEVPOLL_HPP_INCLUDED__
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_HPUX
+// poller.hpp decides which polling mechanism to use.
+#include "poller.hpp"
+#if defined ZMQ_USE_DEVPOLL
#include <vector>
@@ -93,6 +93,8 @@ namespace zmq
const devpoll_t &operator = (const devpoll_t&);
};
+ typedef devpoll_t poller_t;
+
}
#endif
diff --git a/src/epoll.cpp b/src/epoll.cpp
index 2c84f8c..39b4547 100644
--- a/src/epoll.cpp
+++ b/src/epoll.cpp
@@ -18,9 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "platform.hpp"
-
-#ifdef ZMQ_HAVE_LINUX
+#include "epoll.hpp"
+#if defined ZMQ_USE_EPOLL
#include <sys/epoll.h>
#include <stdlib.h>
diff --git a/src/epoll.hpp b/src/epoll.hpp
index 7e5195e..dc6b3ed 100644
--- a/src/epoll.hpp
+++ b/src/epoll.hpp
@@ -21,9 +21,9 @@
#ifndef __ZMQ_EPOLL_HPP_INCLUDED__
#define __ZMQ_EPOLL_HPP_INCLUDED__
-#include "platform.hpp"
-
-#ifdef ZMQ_HAVE_LINUX
+// poller.hpp decides which polling mechanism to use.
+#include "poller.hpp"
+#if defined ZMQ_USE_EPOLL
#include <vector>
#include <sys/epoll.h>
@@ -89,6 +89,8 @@ namespace zmq
const epoll_t &operator = (const epoll_t&);
};
+ typedef epoll_t poller_t;
+
}
#endif
diff --git a/src/kqueue.cpp b/src/kqueue.cpp
index e28ecd7..bb42d8f 100644
--- a/src/kqueue.cpp
+++ b/src/kqueue.cpp
@@ -18,10 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_OPENBSD ||\
- defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_NETBSD
+#include "kqueue.hpp"
+#if defined ZMQ_USE_KQUEUE
#include <sys/time.h>
#include <sys/types.h>
@@ -189,6 +187,4 @@ void zmq::kqueue_t::worker_routine (void *arg_)
((kqueue_t*) arg_)->loop ();
}
-// Don't pollute namespace with defines local to this file
-#undef kevent_udata_t
#endif
diff --git a/src/kqueue.hpp b/src/kqueue.hpp
index d564c7c..4ded81e 100644
--- a/src/kqueue.hpp
+++ b/src/kqueue.hpp
@@ -21,10 +21,9 @@
#ifndef __ZMQ_KQUEUE_HPP_INCLUDED__
#define __ZMQ_KQUEUE_HPP_INCLUDED__
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_OPENBSD ||\
- defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_NETBSD
+// poller.hpp decides which polling mechanism to use.
+#include "poller.hpp"
+#if defined ZMQ_USE_KQUEUE
#include <vector>
@@ -96,6 +95,8 @@ namespace zmq
const kqueue_t &operator = (const kqueue_t&);
};
+ typedef kqueue_t poller_t;
+
}
#endif
diff --git a/src/poll.cpp b/src/poll.cpp
index 6a84d2e..9d1978b 100644
--- a/src/poll.cpp
+++ b/src/poll.cpp
@@ -18,13 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\
- defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\
- defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\
- defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\
- defined ZMQ_HAVE_NETBSD
+#include "poll.hpp"
+#if defined ZMQ_USE_POLL
#include <sys/types.h>
#include <sys/time.h>
diff --git a/src/poll.hpp b/src/poll.hpp
index 3a18d03..42f3af1 100644
--- a/src/poll.hpp
+++ b/src/poll.hpp
@@ -21,13 +21,9 @@
#ifndef __ZMQ_POLL_HPP_INCLUDED__
#define __ZMQ_POLL_HPP_INCLUDED__
-#include "platform.hpp"
-
-#if defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\
- defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\
- defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\
- defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\
- defined ZMQ_HAVE_NETBSD
+// poller.hpp decides which polling mechanism to use.
+#include "poller.hpp"
+#if defined ZMQ_USE_POLL
#include <poll.h>
#include <stddef.h>
@@ -97,6 +93,8 @@ namespace zmq
const poll_t &operator = (const poll_t&);
};
+ typedef poll_t poller_t;
+
}
#endif
diff --git a/src/poller.hpp b/src/poller.hpp
index 10fafb9..a8936ce 100644
--- a/src/poller.hpp
+++ b/src/poller.hpp
@@ -21,53 +21,61 @@
#ifndef __ZMQ_POLLER_HPP_INCLUDED__
#define __ZMQ_POLLER_HPP_INCLUDED__
-#include "epoll.hpp"
-#include "poll.hpp"
-#include "select.hpp"
-#include "devpoll.hpp"
-#include "kqueue.hpp"
-
-namespace zmq
-{
+#include "platform.hpp"
#if defined ZMQ_FORCE_SELECT
- typedef select_t poller_t;
+#define ZMQ_USE_SELECT
+#include "select.hpp"
#elif defined ZMQ_FORCE_POLL
- typedef poll_t poller_t;
+#define ZMQ_USE_POLL
+#include "poll.hpp"
#elif defined ZMQ_FORCE_EPOLL
- typedef epoll_t poller_t;
+#define ZMQ_USE_EPOLL
+#include "epoll.hpp"
#elif defined ZMQ_FORCE_DEVPOLL
- typedef devpoll_t poller_t;
+#define ZMQ_USE_DEVPOLL
+#include "devpoll.hpp"
#elif defined ZMQ_FORCE_KQUEUE
- typedef kqueue_t poller_t;
+#define ZMQ_USE_KQUEUE
+#include "kqueue.hpp"
#elif defined ZMQ_HAVE_LINUX
- typedef epoll_t poller_t;
+#define ZMQ_USE_EPOLL
+#include "epoll.hpp"
#elif defined ZMQ_HAVE_WINDOWS
- typedef select_t poller_t;
+#define ZMQ_USE_SELECT
+#include "select.hpp"
#elif defined ZMQ_HAVE_FREEBSD
- typedef kqueue_t poller_t;
+#define ZMQ_USE_KQUEUE
+#include "kqueue.hpp"
#elif defined ZMQ_HAVE_OPENBSD
- typedef kqueue_t poller_t;
+#define ZMQ_USE_KQUEUE
+#include "kqueue.hpp"
#elif defined ZMQ_HAVE_NETBSD
- typedef kqueue_t poller_t;
+#define ZMQ_USE_KQUEUE
+#include "kqueue.hpp"
#elif defined ZMQ_HAVE_SOLARIS
- typedef devpoll_t poller_t;
+#define ZMQ_USE_DEVPOLL
+#include "devpoll.hpp"
#elif defined ZMQ_HAVE_OSX
- typedef kqueue_t poller_t;
+#define ZMQ_USE_KQUEUE
+#include "kqueue.hpp"
#elif defined ZMQ_HAVE_QNXNTO
- typedef poll_t poller_t;
+#define ZMQ_USE_POLL
+#include "poll.hpp"
#elif defined ZMQ_HAVE_AIX
- typedef poll_t poller_t;
+#define ZMQ_USE_POLL
+#include "poll.hpp"
#elif defined ZMQ_HAVE_HPUX
- typedef devpoll_t poller_t;
+#define ZMQ_USE_DEVPOLL
+#include "devpoll.hpp"
#elif defined ZMQ_HAVE_OPENVMS
- typedef select_t poller_t;
+#define ZMQ_USE_SELECT
+#include "select.hpp"
#elif defined ZMQ_HAVE_CYGWIN
- typedef select_t poller_t;
+#define ZMQ_USE_SELECT
+#include "select.hpp"
#else
#error Unsupported platform
#endif
-}
-
#endif
diff --git a/src/select.cpp b/src/select.cpp
index 5d5ce5d..0ecdcd7 100644
--- a/src/select.cpp
+++ b/src/select.cpp
@@ -18,6 +18,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "select.hpp"
+#if defined ZMQ_USE_SELECT
+
#include "platform.hpp"
#if defined ZMQ_HAVE_WINDOWS
#include "windows.hpp"
@@ -35,7 +38,6 @@
#include <string.h>
#include <algorithm>
-#include "select.hpp"
#include "err.hpp"
#include "config.hpp"
#include "i_poll_events.hpp"
@@ -209,3 +211,4 @@ bool zmq::select_t::is_retired_fd (const fd_entry_t &entry)
return (entry.fd == retired_fd);
}
+#endif
diff --git a/src/select.hpp b/src/select.hpp
index c88dd71..55bc883 100644
--- a/src/select.hpp
+++ b/src/select.hpp
@@ -21,6 +21,10 @@
#ifndef __ZMQ_SELECT_HPP_INCLUDED__
#define __ZMQ_SELECT_HPP_INCLUDED__
+// poller.hpp decides which polling mechanism to use.
+#include "poller.hpp"
+#if defined ZMQ_USE_SELECT
+
#include "platform.hpp"
#include <stddef.h>
@@ -110,7 +114,10 @@ namespace zmq
const select_t &operator = (const select_t&);
};
+ typedef select_t poller_t;
+
}
#endif
+#endif