Select implementation for RIOT. More...

Detailed Description

Select implementation for RIOT.

See also
The Open Group Base Specification Issue 7
Todo:

Omitted from original specification for now:

  • Inclusion of <signal.h>; no POSIX signal handling implemented in RIOT yet
  • pselect() as it uses sigset_t from <signal.h>
  • handling of the writefds and errorfds parameters of select()

Currently, only sockets are supported

Modules

 POSIX wrapper compile configurations
 

Files

file  select.h
 Select types.
 

Data Structures

struct  fd_set
 The fd_set structure. More...
 

Macros

#define POSIX_SELECT_THREAD_FLAG   (1U << 3)
 Thread Flags for POSIX select
 
#define FD_SETSIZE   (CONFIG_POSIX_FD_SET_SIZE)
 Maximum number of file descriptors in an fd_set structure. More...
 

Functions

static void FD_CLR (int fd, fd_set *fdsetp)
 Removes a file descriptor from an fd_set if it is a member. More...
 
static int FD_ISSET (int fd, fd_set *fdsetp)
 Checks if a file descriptor is a member of an fd_set More...
 
static void FD_SET (int fd, fd_set *fdsetp)
 Adds a file descriptor from an fd_set if it is not already a member. More...
 
static void FD_ZERO (fd_set *fdsetp)
 Initializes the descriptor set as an empty set. More...
 
int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
 Examines the given file descriptor sets if they are ready for their respective operation. More...
 

Macro Definition Documentation

◆ FD_SETSIZE

#define FD_SETSIZE   (CONFIG_POSIX_FD_SET_SIZE)

Maximum number of file descriptors in an fd_set structure.

POSIX-compliant version.

Definition at line 75 of file select.h.

Function Documentation

◆ FD_CLR()

static void FD_CLR ( int  fd,
fd_set fdsetp 
)
inlinestatic

Removes a file descriptor from an fd_set if it is a member.

Parameters
[in]fdA file descriptor
[in]fdsetpAn fd_set

Definition at line 91 of file select.h.

◆ FD_ISSET()

static int FD_ISSET ( int  fd,
fd_set fdsetp 
)
inlinestatic

Checks if a file descriptor is a member of an fd_set

Parameters
[in]fdA file descriptor
[in]fdsetpAn fd_set
Returns
non-zero value, if fd is a member of fdsetp
0, if fd is not a member of fdsetp

Definition at line 105 of file select.h.

◆ FD_SET()

static void FD_SET ( int  fd,
fd_set fdsetp 
)
inlinestatic

Adds a file descriptor from an fd_set if it is not already a member.

Parameters
[in]fdA file descriptor
[in]fdsetpAn fd_set

Definition at line 117 of file select.h.

◆ FD_ZERO()

static void FD_ZERO ( fd_set fdsetp)
inlinestatic

Initializes the descriptor set as an empty set.

Parameters
[in]fdsetpAn fd_set

Definition at line 127 of file select.h.

◆ select()

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

Examines the given file descriptor sets if they are ready for their respective operation.

Parameters
[in]nfdsThe range of descriptors tested. The first nfds descriptors shall be checked in each set; that is, the descriptors from zero through nfds - 1 in the descriptor sets shall be examined.
[in,out]readfdsThe set of file descriptors to be checked for being ready to read. Indicates on output which file descriptors are ready to read. May be NULL to check no file descriptors.
[in,out]writefdsThe set of file descriptors to be checked for being ready to write. Indicates on output which file descriptors are ready to write. May be NULL to check no file descriptors. As only sockets are supported for now, these will be ignored
[in,out]errorfdsThe set of file descriptors to be checked for being error conditions pending. Indicates on output which file descriptors have error conditions pending. May be NULL to check no file descriptors. As only sockets are supported for now, these will be ignored
[in]timeoutTimeout for select to block until one or more of the checked file descriptors is ready. Set timeout to all-zero to return immediately without blocking. May be NULL to block indefinitely.
Returns
number of members added to the file descriptor sets on success.
-1 on error, errno is set to indicate the error.