The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
select.h File Reference

select(), built on poll(). More...

#include <sys/time.h>

Go to the source code of this file.

Data Structures

struct  fd_set

Macros

#define FD_SETSIZE   64
#define FD_ZERO(set)
#define FD_SET(fd, set)
#define FD_CLR(fd, set)
#define FD_ISSET(fd, set)

Functions

int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 wait until a descriptor in one of the sets is ready.

Detailed Description

select(), built on poll().

Macro Definition Documentation

◆ FD_SETSIZE

#define FD_SETSIZE   64

◆ FD_ZERO

#define FD_ZERO ( set)
Value:
do \
{ \
for (int fd_zero_i = 0; fd_zero_i < FD_SETSIZE / 32; fd_zero_i++) \
(set)->bits[fd_zero_i] = 0; \
} while (0)
#define FD_SETSIZE
Definition select.h:9

◆ FD_SET

#define FD_SET ( fd,
set )
Value:
((set)->bits[(fd) / 32] |= 1u << ((fd) % 32))

◆ FD_CLR

#define FD_CLR ( fd,
set )
Value:
((set)->bits[(fd) / 32] &= ~(1u << ((fd) % 32)))

◆ FD_ISSET

#define FD_ISSET ( fd,
set )
Value:
(((set)->bits[(fd) / 32] >> ((fd) % 32)) & 1u)

Function Documentation

◆ select()

int select ( int nfds,
fd_set * readfds,
fd_set * writefds,
fd_set * exceptfds,
struct timeval * timeout )

wait until a descriptor in one of the sets is ready.

on return each set holds only its ready descriptors.

Parameters
nfdsone more than the highest descriptor in the sets.
readfdsdescriptors to watch for reading (may be NULL).
writefdsdescriptors to watch for writing (may be NULL).
exceptfdsdescriptors to watch for errors (may be NULL).
timeouthow long to wait (NULL: no limit).
Returns
the number of ready descriptors in all sets, 0 on timeout, or -1 (errno set).