Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
7#ifndef ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_
8#define ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_
9
17#include <zephyr/toolchain.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24typedef struct zsock_fd_set {
25 uint32_t bitset[(CONFIG_POSIX_MAX_FDS + 31) / 32];
27
28
45__syscall int zsock_select(int nfds, zsock_fd_set *readfds,
46 zsock_fd_set *writefds,
47 zsock_fd_set *exceptfds,
48 struct zsock_timeval *timeout);
49
51#define ZSOCK_FD_SETSIZE (sizeof(((zsock_fd_set *)0)->bitset) * 8)
52
66
79int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set);
80
93void ZSOCK_FD_CLR(int fd, zsock_fd_set *set);
94
107void ZSOCK_FD_SET(int fd, zsock_fd_set *set);
108
109#ifdef CONFIG_NET_SOCKETS_POSIX_NAMES
110
111#define fd_set zsock_fd_set
112#define FD_SETSIZE ZSOCK_FD_SETSIZE
113
114static inline int select(int nfds, zsock_fd_set *readfds,
115 zsock_fd_set *writefds, zsock_fd_set *exceptfds,
116 struct timeval *timeout)
117{
118 return zsock_select(nfds, readfds, writefds, exceptfds, timeout);
119}
120
121static inline void FD_ZERO(zsock_fd_set *set)
122{
123 ZSOCK_FD_ZERO(set);
124}
125
126static inline int FD_ISSET(int fd, zsock_fd_set *set)
127{
128 return ZSOCK_FD_ISSET(fd, set);
129}
130
131static inline void FD_CLR(int fd, zsock_fd_set *set)
132{
133 ZSOCK_FD_CLR(fd, set);
134}
135
136static inline void FD_SET(int fd, zsock_fd_set *set)
137{
138 ZSOCK_FD_SET(fd, set);
139}
140
141#endif /* CONFIG_NET_SOCKETS_POSIX_NAMES */
142
143#ifdef __cplusplus
144}
145#endif
146
147#include <syscalls/socket_select.h>
148
153#endif /* ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_ */
#define zsock_timeval
Definition: socket_types.h:49
static void FD_CLR(int fd, zsock_fd_set *set)
Definition: socket_select.h:131
static void FD_ZERO(zsock_fd_set *set)
Definition: socket_select.h:121
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.
static void FD_SET(int fd, zsock_fd_set *set)
Definition: socket_select.h:136
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.
static int select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, zsock_fd_set *exceptfds, struct timeval *timeout)
Definition: socket_select.h:114
static int FD_ISSET(int fd, zsock_fd_set *set)
Definition: socket_select.h:126
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Definition: _timeval.h:22
Definition: socket_select.h:24
uint32_t bitset[(CONFIG_POSIX_MAX_FDS+31)/32]
Definition: socket_select.h:25
Macros to abstract toolchain specific capabilities.