Make non-fake tor_poll robust against -1 fds
[tor.git] / src / common / fakepoll.h
blob783aff0c42239fed8c2d3f203aa19f00c45609a7
1 /* Copyright 2002,2003 Nick Mathewson, Roger Dingledine. */
2 /* See LICENSE for licensing information */
3 /* $Id$ */
5 #ifndef __FAKEPOLL_H
6 #define __FAKEPOLL_H
8 #include "orconfig.h"
10 #define POLL_NO_WARN
12 #if defined(HAVE_POLL_H)
13 #include <poll.h>
14 #elif defined(HAVE_SYS_POLL_H)
15 #include <sys/poll.h>
16 #endif
18 /* If _POLL_EMUL_H_ is defined, then poll is just a just a thin wrapper around
19 * select. On Mac OS 10.3, this wrapper is kinda flaky, and we should
20 * use our own.
22 #if !(defined(HAVE_POLL_H)||defined(HAVE_SYS_POLL_H))&&!defined(_POLL_EMUL_H_)
23 #define USE_FAKE_POLL
24 #endif
26 #if defined USE_FAKE_POLL && !defined(_POLL_EMUL_H_)
27 struct pollfd {
28 int fd;
29 short events;
30 short revents;
33 #define POLLIN 0x0001
34 #define POLLPRI 0x0002
35 #define POLLOUT 0x0004
36 #define POLLERR 0x0008
37 #define POLLHUP 0x0010
38 #define POLLNVAL 0x0020
39 #endif
41 int tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout);
43 #endif
46 Local Variables:
47 mode:c
48 indent-tabs-mode:nil
49 c-basic-offset:2
50 End: