1 /*
2  * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _ESP_PLATFORM_SYS_POLL_H_
8 #define _ESP_PLATFORM_SYS_POLL_H_
9 
10 #define POLLIN      (1u << 0)      /* data other than high-priority may be read without blocking */
11 #define POLLRDNORM  (1u << 1)      /* normal data may be read without blocking */
12 #define POLLRDBAND  (1u << 2)      /* priority data may be read without blocking */
13 #define POLLPRI     (POLLRDBAND)   /* high-priority data may be read without blocking */
14 // Note: POLLPRI is made equivalent to POLLRDBAND in order to fit all these events into one byte
15 #define POLLOUT     (1u << 3)      /* normal data may be written without blocking */
16 #define POLLWRNORM  (POLLOUT)      /* equivalent to POLLOUT */
17 #define POLLWRBAND  (1u << 4)      /* priority data my be written */
18 #define POLLERR     (1u << 5)      /* some poll error occurred */
19 #define POLLHUP     (1u << 6)      /* file descriptor was "hung up" */
20 #define POLLNVAL    (1u << 7)      /* the specified file descriptor is invalid */
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 struct pollfd {
27     int fd;        /* The descriptor. */
28     short events;  /* The event(s) is/are specified here. */
29     short revents; /* Events found are returned here. */
30 };
31 
32 typedef unsigned int nfds_t;
33 
34 int poll(struct pollfd *fds, nfds_t nfds, int timeout);
35 
36 #ifdef __cplusplus
37 } // extern "C"
38 #endif
39 
40 #endif // _ESP_PLATFORM_SYS_POLL_H_
41