Commit 80d1dd81 authored by Joseph Noir's avatar Joseph Noir

Remove socket includes from default mpx header

parent 180bab00
...@@ -57,40 +57,31 @@ ...@@ -57,40 +57,31 @@
# ifndef CAF_WINDOWS # ifndef CAF_WINDOWS
# include <poll.h> # include <poll.h>
# endif # endif
# ifndef POLLRDHUP
# define POLLRDHUP POLLHUP
# endif
# ifndef POLLPRI
# define POLLPRI POLLIN
# endif
#else #else
# define CAF_EPOLL_MULTIPLEXER # define CAF_EPOLL_MULTIPLEXER
# include <sys/epoll.h> # include <sys/epoll.h>
#endif #endif
// Forward declaration for Windows.
struct pollfd;
namespace caf { namespace caf {
namespace io { namespace io {
namespace network { namespace network {
// poll vs epoll backend // poll vs epoll backend
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer #if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
# ifdef CAF_WINDOWS extern const short input_mask;
// From the MSDN: If the POLLPRI flag is set on a socket for the Microsoft extern const short error_mask;
// Winsock provider, the WSAPoll function will fail. extern const short output_mask;
constexpr short input_mask = POLLIN;
# else
constexpr short input_mask = POLLIN | POLLPRI;
# endif
constexpr short error_mask = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
constexpr short output_mask = POLLOUT;
class event_handler; class event_handler;
using multiplexer_data = pollfd; using multiplexer_data = pollfd;
using multiplexer_poll_shadow_data = std::vector<event_handler*>; using multiplexer_poll_shadow_data = std::vector<event_handler*>;
#else #else
# define CAF_EPOLL_MULTIPLEXER # define CAF_EPOLL_MULTIPLEXER
constexpr int input_mask = EPOLLIN; extern const int input_mask;
constexpr int error_mask = EPOLLRDHUP | EPOLLERR | EPOLLHUP; extern const int error_mask;
constexpr int output_mask = EPOLLOUT; extern const int output_mask;
using multiplexer_data = epoll_event; using multiplexer_data = epoll_event;
using multiplexer_poll_shadow_data = native_socket; using multiplexer_poll_shadow_data = native_socket;
#endif #endif
......
...@@ -38,21 +38,35 @@ ...@@ -38,21 +38,35 @@
#include "caf/scheduler/abstract_coordinator.hpp" #include "caf/scheduler/abstract_coordinator.hpp"
#ifdef CAF_WINDOWS #ifdef CAF_WINDOWS
# include <winsock2.h> # ifndef WIN32_LEAN_AND_MEAN
# include <ws2tcpip.h> // socket_size_type, etc. (MSVC20xx) # define WIN32_LEAN_AND_MEAN
# include <windows.h> # endif // WIN32_LEAN_AND_MEAN
# ifndef NOMINMAX
# define NOMINMAX
# endif
# ifdef CAF_MINGW
# undef _WIN32_WINNT
# undef WINVER
# define _WIN32_WINNT WindowsVista
# define WINVER WindowsVista
# include <w32api.h>
# endif
# include <io.h> # include <io.h>
# include <unistd.h> # include <windows.h>
# include <winsock2.h>
# include <ws2ipdef.h>
# include <ws2tcpip.h>
#else #else
# include <cerrno>
# include <netdb.h>
# include <fcntl.h>
# include <unistd.h> # include <unistd.h>
# include <sys/types.h>
# include <arpa/inet.h> # include <arpa/inet.h>
# include <sys/socket.h> # include <cerrno>
# include <fcntl.h>
# include <netdb.h>
# include <netinet/in.h> # include <netinet/in.h>
# include <netinet/ip.h>
# include <netinet/tcp.h> # include <netinet/tcp.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <utility> # include <utility>
#endif #endif
...@@ -94,6 +108,30 @@ namespace caf { ...@@ -94,6 +108,30 @@ namespace caf {
namespace io { namespace io {
namespace network { namespace network {
// poll vs epoll backend
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
# ifndef POLLRDHUP
# define POLLRDHUP POLLHUP
# endif
# ifndef POLLPRI
# define POLLPRI POLLIN
# endif
# ifdef CAF_WINDOWS
// From the MSDN: If the POLLPRI flag is set on a socket for the Microsoft
// Winsock provider, the WSAPoll function will fail.
const short input_mask = POLLIN;
# else
const short input_mask = POLLIN | POLLPRI;
# endif
const short error_mask = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
const short output_mask = POLLOUT;
#else
# define CAF_EPOLL_MULTIPLEXER
const int input_mask = EPOLLIN;
const int error_mask = EPOLLRDHUP | EPOLLERR | EPOLLHUP;
const int output_mask = EPOLLOUT;
#endif
// -- Platform-dependent abstraction over epoll() or poll() -------------------- // -- Platform-dependent abstraction over epoll() or poll() --------------------
#ifdef CAF_EPOLL_MULTIPLEXER #ifdef CAF_EPOLL_MULTIPLEXER
......
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