FreeTDS API: include/replacements/poll.h Source File

FreeTDS API

poll.h
Go to the documentation of this file.
1
5 #if !defined(_REPLACEMENTS_POLL_H) && !defined(HAVE_POLL)
6 #define _REPLACEMENTS_POLL_H
7
8 #include <config.h>
9
10 #if HAVE_LIMITS_H
11 #include <limits.h>
12 #endif
13
14 #if HAVE_SYS_SELECT_H
15 #include <sys/select.h>
16 #endif
17
18 #if defined(_WIN32)
19 #include <winsock2.h>
20 #endif
21
22 #if defined(__VMS)
23 #include <time.h> /* FD_SETSIZE is in here */
24 #endif
25
26 #if !defined(FD_SETSIZE)
27 # if !defined(OPEN_MAX)
28 # error cannot establish FD_SETSIZE
29 # endif
30 #define FD_SETSIZE OPEN_MAX
31 #endif
32
33 #include <freetds/pushvis.h>
34
35 #ifndef _WIN32
36 /* poll flags */
37 # define POLLIN 0x0001
38 # define POLLOUT 0x0004
39 # define POLLERR 0x0008
40
41 /* synonyms */
42 # define POLLNORM POLLIN
43 # define POLLPRI POLLIN
44 # define POLLRDNORM POLLIN
45 # define POLLRDBAND POLLIN
46 # define POLLWRNORM POLLOUT
47 # define POLLWRBAND POLLOUT
48
49 /* ignored */
50 # define POLLHUP 0x0010
51 # define POLLNVAL 0x0020
52 typedef struct pollfd {
53 int fd; /* file descriptor to poll */
54 short events; /* events of interest on fd */
55 short revents; /* events that occurred on fd */
56 } pollfd_t;
57
58 #else /* Windows */
59 /*
60 * Windows use different constants then Unix
61 * Newer version have a WSAPoll which is equal to Unix poll
62 */
63 # if !defined(POLLRDNORM) && !defined(POLLWRNORM)
64 # define POLLIN 0x0300
65 # define POLLOUT 0x0010
66 # define POLLERR 0x0001
67 # define POLLRDNORM 0x0100
68 # define POLLWRNORM 0x0010
69 typedef struct pollfd {
70 SOCKET fd; /* file descriptor to poll */
71 short events; /* events of interest on fd */
72 short revents; /* events that occurred on fd */
73 } pollfd_t;
74 # else
75 typedef struct pollfd pollfd_t;
76 # endif
77 #endif
78
79 #undef poll
80 int tds_poll(struct pollfd fds[], int nfds, int timeout);
81 #define poll(fds, nfds, timeout) tds_poll(fds, nfds, timeout)
82
83 #include <freetds/popvis.h>
84
85 #endif
pollfd
Definition: poll.h:52