Asterisk - The Open Source Telephony Project GIT-master-25686a5
Data Structures | Macros | Functions | Variables
select.h File Reference

Bitfield expansions for ast_select. More...

#include <sys/time.h>
#include <sys/select.h>
#include <errno.h>
#include "asterisk/compat.h"
Include dependency graph for select.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_fdset
 

Macros

#define _bitsize(a)   (sizeof(a) * 8)
 
#define ast_FDMAX   32768
 
#define FD_SET(fd, fds)
 
#define FD_ZERO(a)
 

Functions

static int ast_select (int nfds, ast_fdset *rfds, ast_fdset *wfds, ast_fdset *efds, struct timeval *tvp)
 Waits for activity on a group of channels. More...
 

Variables

unsigned int ast_FD_SETSIZE
 

Detailed Description

Bitfield expansions for ast_select.

Definition in file select.h.

Macro Definition Documentation

◆ _bitsize

#define _bitsize (   a)    (sizeof(a) * 8)

Definition at line 46 of file select.h.

◆ ast_FDMAX

#define ast_FDMAX   32768

Definition at line 41 of file select.h.

◆ FD_SET

#define FD_SET (   fd,
  fds 
)

Definition at line 58 of file select.h.

◆ FD_ZERO

#define FD_ZERO (   a)

Definition at line 49 of file select.h.

Function Documentation

◆ ast_select()

static int ast_select ( int  nfds,
ast_fdset rfds,
ast_fdset wfds,
ast_fdset efds,
struct timeval *  tvp 
)
inlinestatic

Waits for activity on a group of channels.

Parameters
nfdsthe maximum number of file descriptors in the sets
rfdsfile descriptors to check for read availability
wfdsfile descriptors to check for write availability
efdsfile descriptors to check for exceptions (OOB data)
tvptimeout while waiting for events This is the same as a standard select(), except it guarantees the behaviour where the passed struct timeval is updated with how much time was not slept while waiting for the specified events

Definition at line 79 of file select.h.

80{
81#ifdef __linux__
82 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
83#else
84 int save_errno = 0;
85 if (tvp) {
86 struct timeval tv, tvstart, tvend, tvlen;
87 int res;
88
89 tv = *tvp;
90 gettimeofday(&tvstart, NULL);
91 res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
92 save_errno = errno;
93 gettimeofday(&tvend, NULL);
94 timersub(&tvend, &tvstart, &tvlen);
95 timersub(&tv, &tvlen, tvp);
96 if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) {
97 tvp->tv_sec = 0;
98 tvp->tv_usec = 0;
99 }
100 errno = save_errno;
101 return res;
102 }
103 else
104 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, NULL);
105#endif
106}
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
int errno
#define NULL
Definition: resample.c:96

References errno, NULL, and timersub().

Referenced by ast_poll2(), and main().

Variable Documentation

◆ ast_FD_SETSIZE

unsigned int ast_FD_SETSIZE
extern

Definition at line 86 of file poll.c.

Referenced by main().