FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fakepoll.h
1 /* $Id: fakepoll.h,v 1.4 2010-05-12 08:15:27 freddy77 Exp $ */
2 #if !defined(_FAKE_POLL_H) && !defined(HAVE_POLL)
3 #define _FAKE_POLL_H
4 
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 
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 #ifndef _WIN32
34 /* poll flags */
35 # define POLLIN 0x0001
36 # define POLLOUT 0x0004
37 # define POLLERR 0x0008
38 
39 /* synonyms */
40 # define POLLNORM POLLIN
41 # define POLLPRI POLLIN
42 # define POLLRDNORM POLLIN
43 # define POLLRDBAND POLLIN
44 # define POLLWRNORM POLLOUT
45 # define POLLWRBAND POLLOUT
46 
47 /* ignored */
48 # define POLLHUP 0x0010
49 # define POLLNVAL 0x0020
50 typedef struct pollfd {
51  int fd; /* file descriptor to poll */
52  short events; /* events of interest on fd */
53  short revents; /* events that occurred on fd */
54 } pollfd_t;
55 
56 #else /* Windows */
57 /*
58  * Windows use different constants then Unix
59  * Newer version have a WSAPoll which is equal to Unix poll
60  */
61 # if !defined(POLLRDNORM) && !defined(POLLWRNORM)
62 # define POLLIN 0x0300
63 # define POLLOUT 0x0010
64 # define POLLERR 0x0001
65 # define POLLRDNORM 0x0100
66 # define POLLWRNORM 0x0010
67 typedef struct pollfd {
68  SOCKET fd; /* file descriptor to poll */
69  short events; /* events of interest on fd */
70  short revents; /* events that occurred on fd */
71 } pollfd_t;
72 # else
73 typedef struct pollfd pollfd_t;
74 # endif
75 #endif
76 
77 int fakepoll(struct pollfd fds[], int nfds, int timeout);
78 
79 #endif