posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
select.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Linaro Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
20#ifndef ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_
21#define ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_
22
23#include <zephyr/sys/fdtable.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30#define FD_SETSIZE ZVFS_FD_SETSIZE
31
32#if !defined(_SIGSET_T_DECLARED) && !defined(__sigset_t_defined)
33
34#ifndef SIGRTMIN
35#define SIGRTMIN (CONFIG_THREAD_CANCEL_SIGNAL_NUMBER + 2)
36#endif
37#if defined(_POSIX_REALTIME_SIGNALS)
38BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0);
39#ifndef SIGRTMAX
40#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX)
41#endif
42#else
43#ifndef SIGRTMAX
44#define SIGRTMAX SIGRTMIN
45#endif
46#endif
47
48typedef struct {
49 unsigned long sig[DIV_ROUND_UP(SIGRTMAX + 1, BITS_PER_LONG)];
50} sigset_t;
51#define _SIGSET_T_DECLARED
52#define __sigset_t_defined
53#endif
54
55#if !defined(_SUSECONDS_T_DECLARED) && !defined(__suseconds_t_defined)
57typedef long suseconds_t;
58#define _SUSECONDS_T_DECLARED
59#define __suseconds_t_defined
60#endif
61
62/* time_t must be defined by the libc time.h */
63#include <time.h>
64
65#if __STDC_VERSION__ >= 201112L
66/* struct timespec must be defined in the libc time.h */
67#else
68#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined)
70struct timespec {
71 time_t tv_sec;
72 long tv_nsec;
73};
74#define _TIMESPEC_DECLARED
75#define __timespec_defined
76#endif
77#endif
78
79#if !defined(_TIMEVAL_DECLARED) && !defined(__timeval_defined)
81struct timeval {
82 time_t tv_sec;
84};
85#define _TIMEVAL_DECLARED
86#define __timeval_defined
87#endif
88
90typedef struct zvfs_fd_set fd_set;
91
92struct timeval;
93
107int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
108 const struct timespec *timeout, const sigset_t *sigmask);
109
122int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
123
131void FD_CLR(int fd, fd_set *fdset);
132
141int FD_ISSET(int fd, fd_set *fdset);
142
150void FD_SET(int fd, fd_set *fdset);
151
158void FD_ZERO(fd_set *fdset);
159
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif /* ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_ */
void FD_CLR(int fd, fd_set *fdset)
Remove a file descriptor from an fd_set.
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask)
Synchronous multiplexed I/O with signal-mask and nanosecond timeout.
void FD_ZERO(fd_set *fdset)
Clear all file descriptors from an fd_set.
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
Synchronous multiplexed I/O (legacy interface, use pselect() for new code).
void FD_SET(int fd, fd_set *fdset)
Add a file descriptor to an fd_set.
int FD_ISSET(int fd, fd_set *fdset)
Test whether a file descriptor is in an fd_set.
long suseconds_t
Microsecond time component type.
Definition select.h:57
struct zvfs_fd_set fd_set
Set of file descriptors for select()/pselect().
Definition select.h:90
Set of signals (bitmask).
Time value with nanosecond resolution.
Definition aio.h:65
long tv_nsec
Nanoseconds [0, 999999999].
Definition aio.h:67
time_t tv_sec
Seconds.
Definition aio.h:66
Time value with microsecond resolution.
Definition select.h:81
suseconds_t tv_usec
Microseconds [0, 999999].
Definition select.h:83
time_t tv_sec
Seconds.
Definition select.h:82
POSIX time-of-day types and functions (<sys/time.h>)