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