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 32
36#endif
37#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
38BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0);
40#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX)
41#else
42#define SIGRTMAX SIGRTMIN
43#endif
44
46typedef struct {
47 unsigned long sig[DIV_ROUND_UP(SIGRTMAX + 1, BITS_PER_LONG)];
48} sigset_t;
49#define _SIGSET_T_DECLARED
50#define __sigset_t_defined
51#endif
52
53#if !defined(_SUSECONDS_T_DECLARED) && !defined(__suseconds_t_defined)
55typedef long suseconds_t;
56#define _SUSECONDS_T_DECLARED
57#define __suseconds_t_defined
58#endif
59
60/* time_t must be defined by the libc time.h */
61#include <time.h>
62
63#if __STDC_VERSION__ >= 201112L
64/* struct timespec must be defined in the libc time.h */
65#else
66#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined)
68struct timespec {
69 time_t tv_sec;
70 long tv_nsec;
71};
72#define _TIMESPEC_DECLARED
73#define __timespec_defined
74#endif
75#endif
76
77#if !defined(_TIMEVAL_DECLARED) && !defined(__timeval_defined)
79struct timeval {
80 time_t tv_sec;
82};
83#define _TIMEVAL_DECLARED
84#define __timeval_defined
85#endif
86
88typedef struct zvfs_fd_set fd_set;
89
90struct timeval;
91
105int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
106 const struct timespec *timeout, const sigset_t *sigmask);
107
120int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
121
129void FD_CLR(int fd, fd_set *fdset);
130
139int FD_ISSET(int fd, fd_set *fdset);
140
148void FD_SET(int fd, fd_set *fdset);
149
156void FD_ZERO(fd_set *fdset);
157
158
159#ifdef __cplusplus
160}
161#endif
162
163#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.
#define SIGRTMAX
Largest real-time signal number.
Definition select.h:40
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:55
struct zvfs_fd_set fd_set
Set of file descriptors for select()/pselect().
Definition select.h:88
Type representing a set of signals (bitmask).
Time value with nanosecond resolution.
Definition aio.h:62
long tv_nsec
Nanoseconds [0, 999999999].
Definition aio.h:64
time_t tv_sec
Seconds.
Definition aio.h:63
Time value with microsecond resolution.
Definition select.h:79
suseconds_t tv_usec
Microseconds [0, 999999].
Definition select.h:81
time_t tv_sec
Seconds.
Definition select.h:80
POSIX time-of-day types and functions (<sys/time.h>)