Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudio
[platform/upstream/pulseaudio.git] / src / pulsecore / poll.h
1 /***
2   This file is part of PulseAudio.
3
4   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
5
6   PulseAudio is free software; you can redistribute it and/or modify
7   it under the terms of the GNU Lesser General Public License as published
8   by the Free Software Foundation; either version 2.1 of the License,
9   or (at your option) any later version.
10
11   PulseAudio is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public License
17   along with PulseAudio; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19   USA.
20 ***/
21
22 /***
23    Based on work for the GNU C Library.
24    Copyright (C) 1994,96,97,98,99,2000,2001,2004 Free Software Foundation, Inc.
25 ***/
26
27 /* Event types that can be polled for.  These bits may be set in `events'
28    to indicate the interesting event types; they will appear in `revents'
29    to indicate the status of the file descriptor.  */
30 #define POLLIN          0x001           /* There is data to read.  */
31 #define POLLPRI         0x002           /* There is urgent data to read.  */
32 #define POLLOUT         0x004           /* Writing now will not block.  */
33
34 /* Event types always implicitly polled for.  These bits need not be set in
35    `events', but they will appear in `revents' to indicate the status of
36    the file descriptor.  */
37 #define POLLERR         0x008           /* Error condition.  */
38 #define POLLHUP         0x010           /* Hung up.  */
39 #define POLLNVAL        0x020           /* Invalid polling request.  */
40
41
42 /* Type used for the number of file descriptors.  */
43 typedef unsigned long int nfds_t;
44
45 /* Data structure describing a polling request.  */
46 struct pollfd
47   {
48     int fd;                     /* File descriptor to poll.  */
49     short int events;           /* Types of events poller cares about.  */
50     short int revents;          /* Types of events that actually occurred.  */
51   };
52
53 /* Poll the file descriptors described by the NFDS structures starting at
54    FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
55    an event to occur; if TIMEOUT is -1, block until an event occurs.
56    Returns the number of file descriptors with events, zero if timed out,
57    or -1 for errors.  */
58 extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);