fakepoll.h 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright 2002,2003 Nick Mathewson, Roger Dingledine. */
  2. /* See LICENSE for licensing information */
  3. /* $Id$ */
  4. #ifndef __FAKEPOLL_H
  5. #define __FAKEPOLL_H
  6. #include "orconfig.h"
  7. #define POLL_NO_WARN
  8. #if defined(HAVE_POLL_H)
  9. #include <poll.h>
  10. #elif defined(HAVE_SYS_POLL_H)
  11. #include <sys/poll.h>
  12. #endif
  13. /* If _POLL_EMUL_H_ is defined, then poll is just a just a thin wrapper around
  14. * select. On Mac OS 10.3, this wrapper is kinda flakey, and we should
  15. * use our own.
  16. */
  17. #if (defined(HAVE_POLL_H)||defined(HAVE_SYS_POLL_H)) && !defined(_POLL_EMUL_H_)
  18. #define tor_poll poll
  19. #else
  20. #define USE_FAKE_POLL
  21. #endif
  22. #ifdef USE_FAKE_POLL
  23. #ifndef _POLL_EMUL_H_
  24. struct pollfd {
  25. int fd;
  26. short events;
  27. short revents;
  28. };
  29. #define POLLIN 0x0001
  30. #define POLLPRI 0x0002
  31. #define POLLOUT 0x0004
  32. #define POLLERR 0x0008
  33. #define POLLHUP 0x0010
  34. #define POLLNVAL 0x0020
  35. #endif
  36. int tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout);
  37. #endif
  38. #endif