Commit f716b571 authored by Martin Sustrik's avatar Martin Sustrik

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: 's avatarMartin Sustrik <sustrik@250bpm.com>
parent 0e71b111
......@@ -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>
......
......@@ -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
......
......@@ -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>
......
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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>
......
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment