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