27#include <sys/select.h>
38#if !defined(HAVE_VARIABLE_FDSET) && defined(CONFIGURE_RAN_AS_ROOT)
39#define ast_fdset fd_set
41#define ast_FDMAX 32768
46#define _bitsize(a) (sizeof(a) * 8)
51 TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) a; \
53 for (i = 0; i < ast_FDMAX / _bitsize(TYPEOF_FD_SET_FDS_BITS); i++) { \
58#define FD_SET(fd, fds) \
60 TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) fds; \
61 if (fd < ast_FDMAX) { \
62 bytes[fd / _bitsize(*bytes)] |= ((TYPEOF_FD_SET_FDS_BITS) 1) << (fd % _bitsize(*bytes)); \
64 fprintf(stderr, "FD %d exceeds the maximum size of ast_fdset!\n", fd); \
82 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
86 struct timeval tv, tvstart, tvend, tvlen;
90 gettimeofday(&tvstart,
NULL);
91 res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
93 gettimeofday(&tvend,
NULL);
96 if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) {
104 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds,
NULL);
#define TYPEOF_FD_SET_FDS_BITS
#define SIZEOF_FD_SET_FDS_BITS
General Definitions for Asterisk top level program Included by asterisk.h to handle platform-specific...
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
unsigned int ast_FD_SETSIZE
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.