The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
select.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file sys/select.h
5
* @brief select(), built on poll().
6
*/
7
8
// descriptors an fd_set can hold (more than a process can have open)
9
#define FD_SETSIZE 64
10
11
typedef
struct
12
{
13
unsigned
int
bits
[
FD_SETSIZE
/ 32];
14
}
fd_set
;
15
16
#define FD_ZERO(set) \
17
do \
18
{ \
19
for (int fd_zero_i = 0; fd_zero_i < FD_SETSIZE / 32; fd_zero_i++) \
20
(set)->bits[fd_zero_i] = 0; \
21
} while (0)
22
#define FD_SET(fd, set) ((set)->bits[(fd) / 32] |= 1u << ((fd) % 32))
23
#define FD_CLR(fd, set) ((set)->bits[(fd) / 32] &= ~(1u << ((fd) % 32)))
24
#define FD_ISSET(fd, set) (((set)->bits[(fd) / 32] >> ((fd) % 32)) & 1u)
25
26
#include <
sys/time.h
>
27
28
/**
29
* wait until a descriptor in one of the sets is ready. on return each set
30
* holds only its ready descriptors.
31
* @param nfds one more than the highest descriptor in the sets.
32
* @param readfds descriptors to watch for reading (may be NULL).
33
* @param writefds descriptors to watch for writing (may be NULL).
34
* @param exceptfds descriptors to watch for errors (may be NULL).
35
* @param timeout how long to wait (NULL: no limit).
36
* @return the number of ready descriptors in all sets, 0 on timeout, or -1
37
* (errno set).
38
*/
39
int
select
(
int
nfds,
fd_set
*readfds,
fd_set
*writefds,
fd_set
*exceptfds,
40
struct
timeval
*timeout);
FD_SETSIZE
#define FD_SETSIZE
Definition
select.h:9
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.
fd_set
Definition
select.h:12
fd_set::bits
unsigned int bits[FD_SETSIZE/32]
Definition
select.h:13
timeval
Definition
time.h:14
time.h
struct timeval and gettimeofday.
src
libc
include
sys
select.h
Generated by
1.18.0