summaryrefslogtreecommitdiff
path: root/components/libc/posix/io/poll/poll.h
blob: def526ff9d62538e2d6f49d4813c3c77691231d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author            Notes
 * 2021-09-11     Meco Man          First version
 * 2024-03-29     TroyMitchelle     Add all macro comments and comments to structure members
 */

#ifndef __POLL_H__
#define __POLL_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifdef RT_USING_MUSLLIBC
#if !defined(POLLIN) && !defined(POLLOUT)
#define POLLIN     0x001   /**< There is data to read. */
#define POLLPRI    0x002   /**< There is urgent data to read. */
#define POLLOUT    0x004   /**< Writing is now possible. */
#define POLLERR    0x008   /**< Error condition. */
#define POLLHUP    0x010   /**< Hang up. */
#define POLLNVAL   0x020   /**< Invalid polling request. */
#define POLLRDNORM 0x040   /**< Normal data may be read. */
#define POLLRDBAND 0x080   /**< Priority data may be read. */
#define POLLWRNORM 0x100   /**< Writing normal data is possible. */
#define POLLWRBAND 0x200   /**< Writing priority data is possible. */
typedef unsigned int nfds_t;
struct pollfd
{
    int fd;             /**< File descriptor. */
    short events;       /**< Requested events. */
    short revents;      /**< Returned events. */
};
#endif
#else
#if !defined(POLLIN) && !defined(POLLOUT)
#define POLLIN     0x1     /**< There is data to read. */
#define POLLOUT    0x2     /**< Writing is now possible. */
#define POLLERR    0x4     /**< Error condition. */
#define POLLNVAL   0x8     /**< Invalid polling request. */
/* Below values are unimplemented */
#define POLLRDNORM 0x10    /**< Normal data may be read. */
#define POLLRDBAND 0x20    /**< Priority data may be read. */
#define POLLPRI    0x40    /**< There is urgent data to read. */
#define POLLWRNORM 0x80    /**< Writing normal data is possible. */
#define POLLWRBAND 0x100   /**< Writing priority data is possible. */
#define POLLHUP    0x200   /**< Hang up. */
typedef unsigned int nfds_t;
struct pollfd
{
    int fd;             /**< File descriptor. */
    short events;       /**< Requested events. */
    short revents;      /**< Returned events. */
};
#endif
#endif /* !defined(POLLIN) && !defined(POLLOUT) */

#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)

int poll(struct pollfd *fds, nfds_t nfds, int timeout);

#ifdef __cplusplus
}
#endif

#endif /* __POLL_H__ */