Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
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 <time.h>
23
24#include <zephyr/toolchain.h>
26#include <zephyr/sys/fdtable.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
34
49static inline int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds,
50 zsock_fd_set *exceptfds, struct zsock_timeval *timeout)
51{
52 struct timespec to = {
53 .tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec,
54 .tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)};
55
56 return zvfs_select(nfds, readfds, writefds, exceptfds, (timeout == NULL) ? NULL : &to,
57 NULL);
58}
59
61#define ZSOCK_FD_SETSIZE ZVFS_FD_SETSIZE
62
73static inline void ZSOCK_FD_ZERO(zsock_fd_set *set)
74{
75 ZVFS_FD_ZERO(set);
76}
77
88static inline int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set)
89{
90 return ZVFS_FD_ISSET(fd, set);
91}
92
103static inline void ZSOCK_FD_CLR(int fd, zsock_fd_set *set)
104{
105 ZVFS_FD_CLR(fd, set);
106}
107
118static inline void ZSOCK_FD_SET(int fd, zsock_fd_set *set)
119{
120 ZVFS_FD_SET(fd, set);
121}
122
123#ifdef __cplusplus
124}
125#endif
126
131#endif /* ZEPHYR_INCLUDE_NET_SOCKET_SELECT_H_ */
void ZVFS_FD_CLR(int fd, struct zvfs_fd_set *fdset)
void ZVFS_FD_ZERO(struct zvfs_fd_set *fdset)
int ZVFS_FD_ISSET(int fd, struct zvfs_fd_set *fdset)
int zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds, struct zvfs_fd_set *ZRESTRICT writefds, struct zvfs_fd_set *ZRESTRICT errorfds, const struct timespec *ZRESTRICT timeout, const void *ZRESTRICT sigmask)
void ZVFS_FD_SET(int fd, struct zvfs_fd_set *fdset)
static 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.
Definition socket_select.h:49
static void ZSOCK_FD_SET(int fd, zsock_fd_set *set)
Add socket to fd_set.
Definition socket_select.h:118
static void ZSOCK_FD_CLR(int fd, zsock_fd_set *set)
Remove socket from fd_set.
Definition socket_select.h:103
static void ZSOCK_FD_ZERO(zsock_fd_set *set)
Initialize (clear) fd_set.
Definition socket_select.h:73
static int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set)
Check whether socket is a member of fd_set.
Definition socket_select.h:88
#define NSEC_PER_USEC
number of nanoseconds per micorsecond
Definition sys_clock.h:83
socket types definitionis
Definition _timespec.h:22
Definition fdtable.h:226
Macros to abstract toolchain specific capabilities.