jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3KB

  1. // fakepoll.h
  2. // poll using select
  3. // Warning: a call to this poll() takes about 4K of stack space.
  4. // Greg Parker gparker-web@sealiesoftware.com December 2000
  5. // This code is in the public domain and may be copied or modified without
  6. // permission.
  7. // Updated May 2002:
  8. // * fix crash when an fd is less than 0
  9. // * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
  10. // * don't set POLLIN or POLLOUT in revents if it wasn't requested
  11. // in events (only happens when an fd is in the poll set twice)
  12. #ifndef _FAKE_POLL_H
  13. #define _FAKE_POLL_H
  14. #include <limits.h>
  15. #define FD_SETSIZE OPEN_MAX
  16. #include <sys/types.h>
  17. #include <sys/time.h>
  18. #include <unistd.h>
  19. #include <stdlib.h>
  20. #include <errno.h>
  21. typedef struct pollfd {
  22. int fd; /* file desc to poll */
  23. short events; /* events of interest on fd */
  24. short revents; /* events that occurred on fd */
  25. } pollfd_t;
  26. // poll flags
  27. #define POLLIN 0x0001
  28. #define POLLOUT 0x0004
  29. #define POLLERR 0x0008
  30. // synonyms
  31. #define POLLNORM POLLIN
  32. #define POLLPRI POLLIN
  33. #define POLLRDNORM POLLIN
  34. #define POLLRDBAND POLLIN
  35. #define POLLWRNORM POLLOUT
  36. #define POLLWRBAND POLLOUT
  37. // ignored
  38. #define POLLHUP 0x0010
  39. #define POLLNVAL 0x0020
  40. inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout);
  41. #endif