00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * See http://www.asterisk.org for more information about 00005 * the Asterisk project. Please do not directly contact 00006 * any of the maintainers of this project for assistance; 00007 * the project provides a web site, mailing lists and IRC 00008 * channels for your use. 00009 */ 00010 00011 /*---------------------------------------------------------------------------*\ 00012 $Id: poll-compat.h 284478 2010-09-01 18:49:11Z tilghman $ 00013 00014 NAME 00015 00016 poll - select(2)-based poll() emulation function for BSD systems. 00017 00018 SYNOPSIS 00019 #include "poll.h" 00020 00021 struct pollfd 00022 { 00023 int fd; 00024 short events; 00025 short revents; 00026 } 00027 00028 int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) 00029 00030 DESCRIPTION 00031 00032 This file, and the accompanying "poll.c", implement the System V 00033 poll(2) system call for BSD systems (which typically do not provide 00034 poll()). Poll() provides a method for multiplexing input and output 00035 on multiple open file descriptors; in traditional BSD systems, that 00036 capability is provided by select(). While the semantics of select() 00037 differ from those of poll(), poll() can be readily emulated in terms 00038 of select() -- which is how this function is implemented. 00039 00040 REFERENCES 00041 Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. 00042 00043 NOTES 00044 1. This software requires an ANSI C compiler. 00045 00046 LICENSE 00047 00048 This software is released under the following license: 00049 00050 Copyright (c) 1995-2002 Brian M. Clapper 00051 All rights reserved. 00052 00053 Redistribution and use in source and binary forms are 00054 permitted provided that: (1) source distributions retain 00055 this entire copyright notice and comment; (2) modifications 00056 made to the software are prominently mentioned, and a copy 00057 of the original software (or a pointer to its location) are 00058 included; and (3) distributions including binaries display 00059 the following acknowledgement: "This product includes 00060 software developed by Brian M. Clapper <bmc@clapper.org>" 00061 in the documentation or other materials provided with the 00062 distribution. The name of the author may not be used to 00063 endorse or promote products derived from this software 00064 without specific prior written permission. 00065 00066 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS 00067 OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE 00068 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00069 PARTICULAR PURPOSE. 00070 00071 Effectively, this means you can do what you want with the software 00072 except remove this notice or take advantage of the author's name. 00073 If you modify the software and redistribute your modified version, 00074 you must indicate that your version is a modification of the 00075 original, and you must provide either a pointer to or a copy of the 00076 original. 00077 \*---------------------------------------------------------------------------*/ 00078 00079 #ifndef __AST_POLL_COMPAT_H 00080 #define __AST_POLL_COMPAT_H 00081 00082 #include "asterisk/select.h" 00083 00084 #ifndef AST_POLL_COMPAT 00085 00086 #include <sys/poll.h> 00087 00088 #define ast_poll(a, b, c) poll(a, b, c) 00089 00090 #else /* AST_POLL_COMPAT */ 00091 00092 #define POLLIN 0x01 00093 #define POLLPRI 0x02 00094 #define POLLOUT 0x04 00095 #define POLLERR 0x08 00096 #define POLLHUP 0x10 00097 #define POLLNVAL 0x20 00098 00099 struct pollfd { 00100 int fd; 00101 short events; 00102 short revents; 00103 }; 00104 00105 #ifdef __cplusplus 00106 extern "C" { 00107 #endif 00108 00109 #define ast_poll(a, b, c) ast_internal_poll(a, b, c) 00110 00111 int ast_internal_poll(struct pollfd *pArray, unsigned long n_fds, int timeout); 00112 00113 #ifdef __cplusplus 00114 } 00115 #endif 00116 00117 #endif /* AST_POLL_COMPAT */ 00118 00119 /*! 00120 * \brief Same as poll(2), except the time is specified in microseconds and 00121 * the tv argument is modified to indicate the time remaining. 00122 */ 00123 int ast_poll2(struct pollfd *pArray, unsigned long n_fds, struct timeval *tv); 00124 00125 #endif /* __AST_POLL_COMPAT_H */