socket_poll.h 731 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef socket_poll_h
  2. #define socket_poll_h
  3. #include <stdbool.h>
  4. typedef int poll_fd;
  5. struct event {
  6. void * s;
  7. bool read;
  8. bool write;
  9. bool error;
  10. bool eof;
  11. };
  12. static bool sp_invalid(poll_fd fd);
  13. static poll_fd sp_create();
  14. static void sp_release(poll_fd fd);
  15. static int sp_add(poll_fd fd, int sock, void *ud);
  16. static void sp_del(poll_fd fd, int sock);
  17. static int sp_enable(poll_fd, int sock, void *ud, bool read_enable, bool write_enable);
  18. static int sp_wait(poll_fd, struct event *e, int max);
  19. static void sp_nonblocking(int sock);
  20. #ifdef __linux__
  21. #include "socket_epoll.h"
  22. #endif
  23. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
  24. #include "socket_kqueue.h"
  25. #endif
  26. #endif