diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/poll.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/poll.h b/include/poll.h new file mode 100644 index 0000000..37f32cd --- /dev/null +++ b/include/poll.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* | ||
| 2 | * poll(2) emulation for Windows | ||
| 3 | * Public domain | ||
| 4 | * from Dongsheng Song <dongsheng.song@gmail.com> | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef LIBCRYPTOCOMPAT_POLL_H | ||
| 8 | #define LIBCRYPTOCOMPAT_POLL_H | ||
| 9 | |||
| 10 | #ifdef HAVE_POLL | ||
| 11 | #include_next <poll.h> | ||
| 12 | #else | ||
| 13 | |||
| 14 | #include <winsock2.h> | ||
| 15 | |||
| 16 | /* Type used for the number of file descriptors. */ | ||
| 17 | typedef unsigned long int nfds_t; | ||
| 18 | |||
| 19 | #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0600) | ||
| 20 | /* Data structure describing a polling request. */ | ||
| 21 | struct pollfd { | ||
| 22 | int fd; /* file descriptor */ | ||
| 23 | short events; /* requested events */ | ||
| 24 | short revents; /* returned events */ | ||
| 25 | }; | ||
| 26 | |||
| 27 | /* Event types that can be polled */ | ||
| 28 | #define POLLIN 0x001 /* There is data to read. */ | ||
| 29 | #define POLLPRI 0x002 /* There is urgent data to read. */ | ||
| 30 | #define POLLOUT 0x004 /* Writing now will not block. */ | ||
| 31 | |||
| 32 | # define POLLRDNORM 0x040 /* Normal data may be read. */ | ||
| 33 | # define POLLRDBAND 0x080 /* Priority data may be read. */ | ||
| 34 | # define POLLWRNORM 0x100 /* Writing now will not block. */ | ||
| 35 | # define POLLWRBAND 0x200 /* Priority data may be written. */ | ||
| 36 | |||
| 37 | /* Event types always implicitly polled. */ | ||
| 38 | #define POLLERR 0x008 /* Error condition. */ | ||
| 39 | #define POLLHUP 0x010 /* Hung up. */ | ||
| 40 | #define POLLNVAL 0x020 /* Invalid polling request. */ | ||
| 41 | |||
| 42 | #endif | ||
| 43 | |||
| 44 | #ifdef __cplusplus | ||
| 45 | extern "C" { | ||
| 46 | #endif | ||
| 47 | |||
| 48 | int poll(struct pollfd *pfds, nfds_t nfds, int timeout); | ||
| 49 | |||
| 50 | #ifdef __cplusplus | ||
| 51 | } | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #endif /* HAVE_POLL */ | ||
| 55 | |||
| 56 | #endif /* LIBCRYPTOCOMPAT_POLL_H */ | ||
