]> code.delx.au - pulseaudio/blob - src/pulsecore/poll.h
a137d9743e1be4c6fbdfb0d731114d604afd8331
[pulseaudio] / 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 #if defined(HAVE_POLL_H)
28 #include <poll.h>
29 #else
30
31 /* Event types that can be polled for. These bits may be set in `events'
32 to indicate the interesting event types; they will appear in `revents'
33 to indicate the status of the file descriptor. */
34 #define POLLIN 0x001 /* There is data to read. */
35 #define POLLPRI 0x002 /* There is urgent data to read. */
36 #define POLLOUT 0x004 /* Writing now will not block. */
37
38 /* Event types always implicitly polled for. These bits need not be set in
39 `events', but they will appear in `revents' to indicate the status of
40 the file descriptor. */
41 #define POLLERR 0x008 /* Error condition. */
42 #define POLLHUP 0x010 /* Hung up. */
43 #define POLLNVAL 0x020 /* Invalid polling request. */
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
54 /* Poll the file descriptors described by the NFDS structures starting at
55 FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
56 an event to occur; if TIMEOUT is -1, block until an event occurs.
57 Returns the number of file descriptors with events, zero if timed out,
58 or -1 for errors. */
59
60 #endif /* HAVE_POLL_H */
61
62 #if defined(HAVE_POLL_H) && !defined(OS_IS_DARWIN)
63 #define pa_poll(fds,nfds,timeout) poll((fds),(nfds),(timeout))
64 #else
65 int pa_poll (struct pollfd *fds, unsigned long nfds, int timeout);
66 #endif