New module poll, from Paolo Bonzini <bonzini@gnu.org>.
[gnulib.git] / lib / poll_.h
1 /* Header for poll(2) emulation
2    Contributed by Paolo Bonzini.
3
4    Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
5
6    This file is part of gnulib.
7
8    gnulib is free software; you can redistribute it and/or modify it
9    under the terms of the GNU Lesser General Public License as published
10    by the Free Software Foundation; either version 2.1, or (at your option)
11    any later version.
12
13    gnulib is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16    License for more details.
17
18    You should have received a copy of the GNU Lesser General Public License
19    along with gnulib; see the file COPYING.LIB.  If not, write to the Free
20    Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21    USA.  
22  */
23
24 #ifndef GNULIB_POLL_H
25 #define GNULIB_POLL_H
26
27 /* fake a poll(2) environment */
28 #define POLLIN      0x0001      /* any readable data available   */
29 #define POLLPRI     0x0002      /* OOB/Urgent readable data      */
30 #define POLLOUT     0x0004      /* file descriptor is writeable  */
31 #define POLLERR     0x0008      /* some poll error occurred      */
32 #define POLLHUP     0x0010      /* file descriptor was "hung up" */
33 #define POLLNVAL    0x0020      /* requested events "invalid"    */
34 #define POLLRDNORM  0x0040
35 #define POLLRDBAND  0x0080
36 #define POLLWRNORM  0x0100
37 #define POLLWRBAND  0x0200
38
39 struct pollfd
40 {
41   int fd;                       /* which file descriptor to poll */
42   short events;                 /* events we are interested in   */
43   short revents;                /* events found on return        */
44 };
45
46 typedef unsigned long nfds_t;
47
48 extern int poll (struct pollfd *pfd, nfds_t nfd, int timeout);
49
50 /* Define INFTIM only if doing so conforms to POSIX.  */
51 #if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
52 #define INFTIM (-1)
53 #endif
54
55 #endif