poll.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_IO_POLL_HPP_
13 #define ECL_IO_POLL_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include "sockets.hpp"
20 
21 #ifdef ECL_IS_WIN32
22  // nothing special here.
23 #else
24  #include <poll.h>
25 #endif
26 
27 /*****************************************************************************
28 ** Macros
29 *****************************************************************************/
30 
31 #ifdef ECL_IS_WIN32
32  #ifndef POLLRDNORM
33  #define POLLRDNORM 0x0100 /* mapped to read fds_set */
34  #endif
35  #ifndef POLLRDBAND
36  #define POLLRDBAND 0x0200 /* mapped to exception fds_set */
37  #endif
38  #ifndef POLLIN
39  #define POLLIN (POLLRDNORM | POLLRDBAND) /* There is data to read. */
40  #endif
41  #ifndef POLLPRI
42  #define POLLPRI 0x0400 /* There is urgent data to read. */
43  #endif
44 
45  #ifndef POLLWRNORM
46  #define POLLWRNORM 0x0010 /* mapped to write fds_set */
47  #endif
48  #ifndef POLLOUT
49  #define POLLOUT (POLLWRNORM) /* Writing now will not block. */
50  #endif
51  #ifndef POLLWRBAND
52  #define POLLWRBAND 0x0020 /* mapped to write fds_set */
53  #endif
54  #ifndef POLLERR
55  #define POLLERR 0x0001 /* Error condition. */
56  #endif
57  #ifndef POLLHUP
58  #define POLLHUP 0x0002 /* Hung up. */
59  #endif
60  #ifndef POLLNVAL
61  #define POLLNVAL 0x0004 /* Invalid polling request. */
62  #endif
63 #else
64  // Nothing to see here!
65 #endif
66 
67 /*****************************************************************************
68 ** Namespaces
69 *****************************************************************************/
70 
71 namespace ecl {
72 
73 /*****************************************************************************
74 ** Types
75 *****************************************************************************/
76 
77 #ifdef ECL_IS_WIN32
78  /* poll emulation support */
79  typedef struct socket_pollfd {
80  socket_descriptor fd; /* file descriptor */
81  short events; /* requested events */
82  short revents; /* returned events */
83  } socket_pollfd;
84 
85  typedef unsigned long int nfds_t;
86 #else
87  typedef struct pollfd socket_pollfd;
88  typedef ::nfds_t ndfs_t;
89 #endif
90 
91 
92  ecl_io_PUBLIC int poll_sockets(socket_pollfd *fds, nfds_t nfds, int timeout);
93 
94 } // namespace ecl
95 
96 #endif /* ECL_IO_POLL_HPP_ */
::nfds_t ndfs_t
Definition: poll.hpp:88
int socket_descriptor
Cross-platform typedef for a socket file descriptor.
Definition: sockets.hpp:58
struct pollfd socket_pollfd
Definition: poll.hpp:87
ecl_io_PUBLIC int poll_sockets(socket_pollfd *fds, nfds_t nfds, int timeout)
Definition: lib/poll.cpp:25
#define ecl_io_PUBLIC
Definition: macros.hpp:28
Cross platform socket api.


ecl_io
Author(s): Daniel Stonier
autogenerated on Fri Jun 7 2019 21:52:45