8c0ad1ff25eb17af58bac306d8acc87ef712a692
[m6w6/libmemcached] / src / libmemcached / poll.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #if defined HAVE_SYS_POLL_H
19 # include <sys/poll.h>
20 #elif defined HAVE_POLL_H
21 # include <poll.h>
22 #elif defined _WIN32
23 # include "windows.hpp"
24 # define poll WSAPoll
25 typedef int nfds_t;
26 #elif !defined _MSC_VER
27
28 # ifdef __cplusplus
29 extern "C" {
30 # endif
31
32 typedef struct pollfd {
33 # if defined(_WIN32)
34 SOCKET fd;
35 # else
36 int fd;
37 # endif
38 short events;
39 short revents;
40 } pollfd_t;
41
42 typedef int nfds_t;
43
44 # define POLLIN 0x0001
45 # define POLLOUT 0x0004
46 # define POLLERR 0x0008
47 # define POLLHUP 0x010 /* Hung up. */
48 # define POLLNVAL 0x020 /* Invalid polling request. */
49
50 int poll(struct pollfd fds[], nfds_t nfds, int tmo);
51
52 # ifdef __cplusplus
53 }
54 # endif
55
56 #endif // defined(_WIN32)