Zephyr API 3.6.99
Loading...
Searching...
No Matches
socket_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
12#ifndef ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_
13#define ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_
14
22#include <zephyr/toolchain.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30typedef struct zsock_fd_set {
31 uint32_t bitset[(CONFIG_ZVFS_OPEN_MAX + 31) / 32];
33
48__syscall int zsock_select(int nfds, zsock_fd_set *readfds,
49 zsock_fd_set *writefds,
50 zsock_fd_set *exceptfds,
51 struct zsock_timeval *timeout);
52
54#define ZSOCK_FD_SETSIZE (sizeof(((zsock_fd_set *)0)->bitset) * 8)
55
67
78int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set);
79
90void ZSOCK_FD_CLR(int fd, zsock_fd_set *set);
91
102void ZSOCK_FD_SET(int fd, zsock_fd_set *set);
103
106#ifdef CONFIG_NET_SOCKETS_POSIX_NAMES
107
108#define fd_set zsock_fd_set
109#define FD_SETSIZE ZSOCK_FD_SETSIZE
110
111static inline int select(int nfds, zsock_fd_set *readfds,
112 zsock_fd_set *writefds, zsock_fd_set *exceptfds,
113 struct timeval *timeout)
114{
115 return zsock_select(nfds, readfds, writefds, exceptfds, timeout);
116}
117
118static inline void FD_ZERO(zsock_fd_set *set)
119{
120 ZSOCK_FD_ZERO(set);
121}
122
123static inline int FD_ISSET(int fd, zsock_fd_set *set)
124{
125 return ZSOCK_FD_ISSET(fd, set);
126}
127
128static inline void FD_CLR(int fd, zsock_fd_set *set)
129{
130 ZSOCK_FD_CLR(fd, set);
131}
132
133static inline void FD_SET(int fd, zsock_fd_set *set)
134{
135 ZSOCK_FD_SET(fd, set);
136}
137
138#endif /* CONFIG_NET_SOCKETS_POSIX_NAMES */
139
142#ifdef __cplusplus
143}
144#endif
145
146#include <zephyr/syscalls/socket_select.h>
147
152#endif /* ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_ */
struct zsock_fd_set zsock_fd_set
Socket file descriptor set.
int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set)
Check whether socket is a member of fd_set.
int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, zsock_fd_set *exceptfds, struct zsock_timeval *timeout)
Legacy function to poll multiple sockets for events.
void ZSOCK_FD_SET(int fd, zsock_fd_set *set)
Add socket to fd_set.
void ZSOCK_FD_CLR(int fd, zsock_fd_set *set)
Remove socket from fd_set.
void ZSOCK_FD_ZERO(zsock_fd_set *set)
Initialize (clear) fd_set.
#define FD_SET
Definition select.h:19
#define FD_CLR
Definition select.h:20
int select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, zsock_fd_set *exceptfds, struct timeval *timeout)
#define FD_ZERO
Definition select.h:18
#define FD_ISSET
Definition select.h:21
socket types definitionis
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Definition _timeval.h:22
Socket file descriptor set.
Definition socket_select.h:30
uint32_t bitset[(CONFIG_ZVFS_OPEN_MAX+31)/32]
Definition socket_select.h:31
Macros to abstract toolchain specific capabilities.