fakepoll.h 2.4 KB

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