Mon Jun 27 16:51:21 2011

Asterisk developer's documentation


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"

Go to the source code of this file.

Data Structures

struct  ast_fdset

Defines

#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 FD_SET ( fd,
fds   ) 

Definition at line 55 of file select.h.

Referenced by main(), and wait_result().

#define FD_ZERO (  ) 

Definition at line 46 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 76 of file select.h.

References errno, and timersub().

Referenced by ast_poll2(), and main().

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


Variable Documentation

unsigned int ast_FD_SETSIZE

Definition at line 86 of file poll.c.

Referenced by main().


Generated on Mon Jun 27 16:51:21 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7