Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
freertos_select/sys/select.h
Go to the documentation of this file.
1
34#ifndef _SYS_SELECT_H_
35#define _SYS_SELECT_H_
36
37/* We can actually pull the FD Set macros from here */
38#include <sys/types.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifndef _SYS_TYPES_FD_SET
45// This is probably a very old armgcc that does not define the FD_SET macros.
46
47# define NBBY 8 /* number of bits in a byte */
48/*
49 * Select uses bit masks of file descriptors in longs.
50 * These macros manipulate such bit fields (the filesystem macros use chars).
51 * FD_SETSIZE may be defined by the user, but the default here
52 * should be >= NOFILE (param.h).
53 */
54# ifndef FD_SETSIZE
55# define FD_SETSIZE 64
56# endif
57
58typedef long fd_mask;
59# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
60# ifndef howmany
61# define howmany(x,y) (((x)+((y)-1))/(y))
62# endif
63
64/* We use a macro for fd_set so that including Sockets.h afterwards
65 can work. */
66typedef struct _types_fd_set {
67 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
69
70#define fd_set _types_fd_set
71
72# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
73# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
74# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
75# define FD_ZERO(p) (__extension__ (void)({ \
76 size_t __i; \
77 char *__tmp = (char *)p; \
78 for (__i = 0; __i < sizeof (*(p)); ++__i) \
79 *__tmp++ = 0; \
80}))
81
82#endif // !defined _SYS_TYPES_FD_SET
83
94int select(int nfds, fd_set *readfds, fd_set *writefds,
95 fd_set *exceptfds, struct timeval *timeout);
96
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* _SYS_SELECT_H_ */
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
POSIX select().
Definition Fileio.cxx:473