fakepoll.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* $Id$ */
  2. /*
  3. * fakepoll.h
  4. *
  5. * On systems where 'poll' doesn't exist, fake it with 'select'.
  6. *
  7. * Copyright (c) 2001-2003, Nick Mathewson <nickm@freehaven.net>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are
  11. * met:
  12. *
  13. * * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * * Redistributions in binary form must reproduce the above
  17. * copyright notice, this list of conditions and the following disclaimer
  18. * in the documentation and/or other materials provided with the
  19. * distribution.
  20. *
  21. * * Neither the names of the copyright owners nor the names of its
  22. * contributors may be used to endorse or promote products derived from
  23. * this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #pragma once
  38. /* don't warn on OS X that poll is emulated */
  39. #define POLL_NO_WARN
  40. #define SYS_POLL_NO_WARN
  41. #ifdef HAVE_POLL_H
  42. #include <poll.h>
  43. #define __FAKEPOLL_H
  44. #elif HAVE_SYS_POLL_H
  45. #include <sys/poll.h>
  46. #define __FAKEPOLL_H
  47. #endif
  48. #ifndef __FAKEPOLL_H
  49. #define __FAKEPOLL_H
  50. #include "config.h"
  51. #ifndef HAVE_POLL_H
  52. #ifndef HAVE_SYS_POLL_H
  53. #define USE_FAKE_POLL
  54. struct pollfd {
  55. int fd;
  56. short events;
  57. short revents;
  58. };
  59. #define POLLIN 0x0001
  60. #define POLLPRI 0x0002
  61. #define POLLOUT 0x0004
  62. #define POLLERR 0x0008
  63. #define POLLHUP 0x0010
  64. #define POLLNVAL 0x0020
  65. int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
  66. #endif
  67. #endif
  68. #endif