Sat Aug 6 00:40:05 2011

Asterisk developer's documentation


select.h File Reference

Bitfield expansions for ast_select. More...

#include "asterisk/autoconfig.h"
#include <sys/select.h>
#include <errno.h>
#include "asterisk/utils.h"

Go to the source code of this file.

Data Structures

struct  ast_fdset

Defines

#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.

Variables

unsigned int ast_FD_SETSIZE


Detailed Description

Bitfield expansions for ast_select.

Definition in file select.h.


Define Documentation

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

Definition at line 45 of file select.h.

#define ast_FDMAX   32768

Definition at line 40 of file select.h.

Referenced by main().

#define FD_SET ( fd,
fds   ) 

Definition at line 57 of file select.h.

Referenced by main(), and wait_result().

#define FD_ZERO (  ) 

Definition at line 48 of file select.h.

Referenced by ast_poll2(), main(), and wait_result().


Function Documentation

static int ast_select ( int  nfds,
ast_fdset rfds,
ast_fdset wfds,
ast_fdset efds,
struct timeval *  tvp 
) [inline, static]

Waits for activity on a group of channels.

Parameters:
nfds the maximum number of file descriptors in the sets
rfds file descriptors to check for read availability
wfds file descriptors to check for write availability
efds file descriptors to check for exceptions (OOB data)
tvp timeout 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 80 of file select.h.

References ast_assert, and errno.

Referenced by ast_poll2(), and main().

00081 {
00082 #ifdef __linux__
00083    ast_assert((unsigned int) nfds <= ast_FD_SETSIZE);
00084    return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
00085 #else
00086    int save_errno = 0;
00087 
00088    ast_assert((unsigned int) nfds <= ast_FD_SETSIZE);
00089    if (tvp) {
00090       struct timeval tv, tvstart, tvend, tvlen;
00091       int res;
00092 
00093       tv = *tvp;
00094       gettimeofday(&tvstart, NULL);
00095       res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
00096       save_errno = errno;
00097       gettimeofday(&tvend, NULL);
00098       timersub(&tvend, &tvstart, &tvlen);
00099       timersub(&tv, &tvlen, tvp);
00100       if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) {
00101          tvp->tv_sec = 0;
00102          tvp->tv_usec = 0;
00103       }
00104       errno = save_errno;
00105       return res;
00106    }
00107    else
00108       return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, NULL);
00109 #endif
00110 }


Variable Documentation

unsigned int ast_FD_SETSIZE

Definition at line 250 of file asterisk.c.

Referenced by main().


Generated on Sat Aug 6 00:40:05 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7