KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
select.h File Reference

Definitions for the select() function. More...

#include <sys/cdefs.h>
#include <sys/types.h>
#include <newlib.h>
#include <kos/opts.h>
#include <time.h>
#include <sys/time.h>

Go to the source code of this file.

Data Structures

struct  fd_set
 Represents a set of file descriptors. More...
 

Macros

#define _SYS_TYPES_FD_SET
 
#define NFDBITS   32
 
#define FD_SET(n, p)   ((p)->fds_bits[(n) / NFDBITS] |= (1 << ((n) % NFDBITS)))
 
#define FD_CLR(n, p)   ((p)->fds_bits[(n) / NFDBITS] &= ~(1 << ((n) % NFDBITS)))
 
#define FD_ISSET(n, p)   ((p)->fds_bits[(n) / NFDBITS] & (1 << ((n) % NFDBITS)))
 
#define FD_ZERO(p)
 

Functions

int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
 Wait for activity on a group of file descriptors.
 

Detailed Description

Definitions for the select() function.

This file contains the definitions needed for using the select() function, as directed by the POSIX 2008 standard (aka The Open Group Base Specifications Issue 7). Currently the functionality defined herein only really works for sockets, and that is likely how it will stay for some time.

Author
Lawrence Sebald

Macro Definition Documentation

◆ _SYS_TYPES_FD_SET

#define _SYS_TYPES_FD_SET

◆ FD_CLR

#define FD_CLR ( n,
p )   ((p)->fds_bits[(n) / NFDBITS] &= ~(1 << ((n) % NFDBITS)))

◆ FD_ISSET

#define FD_ISSET ( n,
p )   ((p)->fds_bits[(n) / NFDBITS] & (1 << ((n) % NFDBITS)))

◆ FD_SET

#define FD_SET ( n,
p )   ((p)->fds_bits[(n) / NFDBITS] |= (1 << ((n) % NFDBITS)))

◆ FD_ZERO

#define FD_ZERO ( p)
Value:
do { \
int __i; \
for(__i = 0; __i < FD_SETSIZE / NFDBITS; ++__i) { \
(p)->fds_bits[__i] = 0; \
} \
} while(0)
#define FD_SETSIZE
The number of distinct file descriptors, including files and network sockets, that can be in use at a...
Definition opts.h:136
#define NFDBITS
Definition select.h:45

◆ NFDBITS

#define NFDBITS   32

Function Documentation

◆ select()

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

Wait for activity on a group of file descriptors.

This function will check the specified group of file descriptors for activity and wait for activity (up to the timeout specified) if there is not any pending events already.

Parameters
nfdsThe maximum fd specified in any of the sets, plus 1.
readfdsFile descriptors to check for the ability to read without blocking.
writefdsFile descriptors to check for the ability to write without blocking.
errorfdsFile descriptors to check for error/exceptional conditions.
timeoutMaximum amount of time to block. Passing a 0 timeout will make the function not block, Passing NULL here will make the function block indefinitely.
Returns
-1 on error (sets errno as appropriate), or the number of bits set in the fd sets on success (this may be 0 if the timeout expires).