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>
This commit is contained in:
Martin Sustrik 2011-07-24 18:13:29 +02:00
parent 0e71b111f4
commit f716b571ba
11 changed files with 74 additions and 64 deletions

View File

@ -18,9 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "platform.hpp" #include "devpoll.hpp"
#if defined ZMQ_USE_DEVPOLL
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_HPUX
#include <sys/devpoll.h> #include <sys/devpoll.h>
#include <sys/time.h> #include <sys/time.h>

View File

@ -21,9 +21,9 @@
#ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__ #ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__
#define __ZMQ_DEVPOLL_HPP_INCLUDED__ #define __ZMQ_DEVPOLL_HPP_INCLUDED__
#include "platform.hpp" // poller.hpp decides which polling mechanism to use.
#include "poller.hpp"
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_HPUX #if defined ZMQ_USE_DEVPOLL
#include <vector> #include <vector>
@ -93,6 +93,8 @@ namespace zmq
const devpoll_t &operator = (const devpoll_t&); const devpoll_t &operator = (const devpoll_t&);
}; };
typedef devpoll_t poller_t;
} }
#endif #endif

View File

@ -18,9 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "platform.hpp" #include "epoll.hpp"
#if defined ZMQ_USE_EPOLL
#ifdef ZMQ_HAVE_LINUX
#include <sys/epoll.h> #include <sys/epoll.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -21,9 +21,9 @@
#ifndef __ZMQ_EPOLL_HPP_INCLUDED__ #ifndef __ZMQ_EPOLL_HPP_INCLUDED__
#define __ZMQ_EPOLL_HPP_INCLUDED__ #define __ZMQ_EPOLL_HPP_INCLUDED__
#include "platform.hpp" // poller.hpp decides which polling mechanism to use.
#include "poller.hpp"
#ifdef ZMQ_HAVE_LINUX #if defined ZMQ_USE_EPOLL
#include <vector> #include <vector>
#include <sys/epoll.h> #include <sys/epoll.h>
@ -89,6 +89,8 @@ namespace zmq
const epoll_t &operator = (const epoll_t&); const epoll_t &operator = (const epoll_t&);
}; };
typedef epoll_t poller_t;
} }
#endif #endif

View File

@ -18,10 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "platform.hpp" #include "kqueue.hpp"
#if defined ZMQ_USE_KQUEUE
#if defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_OPENBSD ||\
defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_NETBSD
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
@ -189,6 +187,4 @@ void zmq::kqueue_t::worker_routine (void *arg_)
((kqueue_t*) arg_)->loop (); ((kqueue_t*) arg_)->loop ();
} }
// Don't pollute namespace with defines local to this file
#undef kevent_udata_t
#endif #endif

View File

@ -21,10 +21,9 @@
#ifndef __ZMQ_KQUEUE_HPP_INCLUDED__ #ifndef __ZMQ_KQUEUE_HPP_INCLUDED__
#define __ZMQ_KQUEUE_HPP_INCLUDED__ #define __ZMQ_KQUEUE_HPP_INCLUDED__
#include "platform.hpp" // poller.hpp decides which polling mechanism to use.
#include "poller.hpp"
#if defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_OPENBSD ||\ #if defined ZMQ_USE_KQUEUE
defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_NETBSD
#include <vector> #include <vector>
@ -96,6 +95,8 @@ namespace zmq
const kqueue_t &operator = (const kqueue_t&); const kqueue_t &operator = (const kqueue_t&);
}; };
typedef kqueue_t poller_t;
} }
#endif #endif

View File

@ -18,13 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "platform.hpp" #include "poll.hpp"
#if defined ZMQ_USE_POLL
#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 <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>

View File

@ -21,13 +21,9 @@
#ifndef __ZMQ_POLL_HPP_INCLUDED__ #ifndef __ZMQ_POLL_HPP_INCLUDED__
#define __ZMQ_POLL_HPP_INCLUDED__ #define __ZMQ_POLL_HPP_INCLUDED__
#include "platform.hpp" // poller.hpp decides which polling mechanism to use.
#include "poller.hpp"
#if defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\ #if defined ZMQ_USE_POLL
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.h> #include <poll.h>
#include <stddef.h> #include <stddef.h>
@ -97,6 +93,8 @@ namespace zmq
const poll_t &operator = (const poll_t&); const poll_t &operator = (const poll_t&);
}; };
typedef poll_t poller_t;
} }
#endif #endif

View File

@ -21,53 +21,61 @@
#ifndef __ZMQ_POLLER_HPP_INCLUDED__ #ifndef __ZMQ_POLLER_HPP_INCLUDED__
#define __ZMQ_POLLER_HPP_INCLUDED__ #define __ZMQ_POLLER_HPP_INCLUDED__
#include "epoll.hpp" #include "platform.hpp"
#include "poll.hpp"
#include "select.hpp"
#include "devpoll.hpp"
#include "kqueue.hpp"
namespace zmq
{
#if defined ZMQ_FORCE_SELECT #if defined ZMQ_FORCE_SELECT
typedef select_t poller_t; #define ZMQ_USE_SELECT
#include "select.hpp"
#elif defined ZMQ_FORCE_POLL #elif defined ZMQ_FORCE_POLL
typedef poll_t poller_t; #define ZMQ_USE_POLL
#include "poll.hpp"
#elif defined ZMQ_FORCE_EPOLL #elif defined ZMQ_FORCE_EPOLL
typedef epoll_t poller_t; #define ZMQ_USE_EPOLL
#include "epoll.hpp"
#elif defined ZMQ_FORCE_DEVPOLL #elif defined ZMQ_FORCE_DEVPOLL
typedef devpoll_t poller_t; #define ZMQ_USE_DEVPOLL
#include "devpoll.hpp"
#elif defined ZMQ_FORCE_KQUEUE #elif defined ZMQ_FORCE_KQUEUE
typedef kqueue_t poller_t; #define ZMQ_USE_KQUEUE
#include "kqueue.hpp"
#elif defined ZMQ_HAVE_LINUX #elif defined ZMQ_HAVE_LINUX
typedef epoll_t poller_t; #define ZMQ_USE_EPOLL
#include "epoll.hpp"
#elif defined ZMQ_HAVE_WINDOWS #elif defined ZMQ_HAVE_WINDOWS
typedef select_t poller_t; #define ZMQ_USE_SELECT
#include "select.hpp"
#elif defined ZMQ_HAVE_FREEBSD #elif defined ZMQ_HAVE_FREEBSD
typedef kqueue_t poller_t; #define ZMQ_USE_KQUEUE
#include "kqueue.hpp"
#elif defined ZMQ_HAVE_OPENBSD #elif defined ZMQ_HAVE_OPENBSD
typedef kqueue_t poller_t; #define ZMQ_USE_KQUEUE
#include "kqueue.hpp"
#elif defined ZMQ_HAVE_NETBSD #elif defined ZMQ_HAVE_NETBSD
typedef kqueue_t poller_t; #define ZMQ_USE_KQUEUE
#include "kqueue.hpp"
#elif defined ZMQ_HAVE_SOLARIS #elif defined ZMQ_HAVE_SOLARIS
typedef devpoll_t poller_t; #define ZMQ_USE_DEVPOLL
#include "devpoll.hpp"
#elif defined ZMQ_HAVE_OSX #elif defined ZMQ_HAVE_OSX
typedef kqueue_t poller_t; #define ZMQ_USE_KQUEUE
#include "kqueue.hpp"
#elif defined ZMQ_HAVE_QNXNTO #elif defined ZMQ_HAVE_QNXNTO
typedef poll_t poller_t; #define ZMQ_USE_POLL
#include "poll.hpp"
#elif defined ZMQ_HAVE_AIX #elif defined ZMQ_HAVE_AIX
typedef poll_t poller_t; #define ZMQ_USE_POLL
#include "poll.hpp"
#elif defined ZMQ_HAVE_HPUX #elif defined ZMQ_HAVE_HPUX
typedef devpoll_t poller_t; #define ZMQ_USE_DEVPOLL
#include "devpoll.hpp"
#elif defined ZMQ_HAVE_OPENVMS #elif defined ZMQ_HAVE_OPENVMS
typedef select_t poller_t; #define ZMQ_USE_SELECT
#include "select.hpp"
#elif defined ZMQ_HAVE_CYGWIN #elif defined ZMQ_HAVE_CYGWIN
typedef select_t poller_t; #define ZMQ_USE_SELECT
#include "select.hpp"
#else #else
#error Unsupported platform #error Unsupported platform
#endif #endif
}
#endif #endif

View File

@ -18,6 +18,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "select.hpp"
#if defined ZMQ_USE_SELECT
#include "platform.hpp" #include "platform.hpp"
#if defined ZMQ_HAVE_WINDOWS #if defined ZMQ_HAVE_WINDOWS
#include "windows.hpp" #include "windows.hpp"
@ -35,7 +38,6 @@
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
#include "select.hpp"
#include "err.hpp" #include "err.hpp"
#include "config.hpp" #include "config.hpp"
#include "i_poll_events.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); return (entry.fd == retired_fd);
} }
#endif

View File

@ -21,6 +21,10 @@
#ifndef __ZMQ_SELECT_HPP_INCLUDED__ #ifndef __ZMQ_SELECT_HPP_INCLUDED__
#define __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 "platform.hpp"
#include <stddef.h> #include <stddef.h>
@ -110,7 +114,10 @@ namespace zmq
const select_t &operator = (const select_t&); const select_t &operator = (const select_t&);
}; };
typedef select_t poller_t;
} }
#endif #endif
#endif