fakepoll.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* don't warn on OS X that poll is emulated */
  38. #define POLL_NO_WARN
  39. #define SYS_POLL_NO_WARN
  40. #ifdef HAVE_POLL_H
  41. #include <poll.h>
  42. #define __FAKEPOLL_H
  43. #elif HAVE_SYS_POLL_H
  44. #include <sys/poll.h>
  45. #define __FAKEPOLL_H
  46. #endif
  47. #ifndef __FAKEPOLL_H
  48. #define __FAKEPOLL_H
  49. #include "config.h"
  50. #ifndef HAVE_POLL_H
  51. #ifndef HAVE_SYS_POLL_H
  52. #define USE_FAKE_POLL
  53. struct pollfd {
  54. int fd;
  55. short events;
  56. short revents;
  57. };
  58. #define POLLIN 0x0001
  59. #define POLLPRI 0x0002
  60. #define POLLOUT 0x0004
  61. #define POLLERR 0x0008
  62. #define POLLHUP 0x0010
  63. #define POLLNVAL 0x0020
  64. int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
  65. #endif
  66. #endif
  67. #endif