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

Remove socket includes from default mpx header

parent 180bab00
......@@ -57,40 +57,31 @@
# ifndef CAF_WINDOWS
# include <poll.h>
# endif
# ifndef POLLRDHUP
# define POLLRDHUP POLLHUP
# endif
# ifndef POLLPRI
# define POLLPRI POLLIN
# endif
#else
# define CAF_EPOLL_MULTIPLEXER
# include <sys/epoll.h>
#endif
// Forward declaration for Windows.
struct pollfd;
namespace caf {
namespace io {
namespace network {
// poll vs epoll backend
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
# 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.
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;
extern const short input_mask;
extern const short error_mask;
extern const short output_mask;
class event_handler;
using multiplexer_data = pollfd;
using multiplexer_poll_shadow_data = std::vector<event_handler*>;
#else
# define CAF_EPOLL_MULTIPLEXER
constexpr int input_mask = EPOLLIN;
constexpr int error_mask = EPOLLRDHUP | EPOLLERR | EPOLLHUP;
constexpr int output_mask = EPOLLOUT;
extern const int input_mask;
extern const int error_mask;
extern const int output_mask;
using multiplexer_data = epoll_event;
using multiplexer_poll_shadow_data = native_socket;
#endif
......
......@@ -38,21 +38,35 @@
#include "caf/scheduler/abstract_coordinator.hpp"
#ifdef CAF_WINDOWS
# include <winsock2.h>
# include <ws2tcpip.h> // socket_size_type, etc. (MSVC20xx)
# include <windows.h>
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# 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 <unistd.h>
# include <windows.h>
# include <winsock2.h>
# include <ws2ipdef.h>
# include <ws2tcpip.h>
#else
# include <cerrno>
# include <netdb.h>
# include <fcntl.h>
# include <unistd.h>
# include <sys/types.h>
# include <arpa/inet.h>
# include <sys/socket.h>
# include <cerrno>
# include <fcntl.h>
# include <netdb.h>
# include <netinet/in.h>
# include <netinet/ip.h>
# include <netinet/tcp.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <utility>
#endif
......@@ -94,6 +108,30 @@ namespace caf {
namespace io {
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() --------------------
#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