A clone of btpd with my configuration changes.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.1 KiB

  1. #ifndef BTPD_EVLOOP_H
  2. #define BTPD_EVLOOP_H
  3. #include <sys/time.h>
  4. #include <stdint.h>
  5. #include "timeheap.h"
  6. #define EV_READ 1
  7. #define EV_WRITE 2
  8. #define EV_TIMEOUT 3
  9. typedef void (*evloop_cb_t)(int fd, short type, void *arg);
  10. #if defined(EVLOOP_EPOLL) || defined(EVLOOP_KQUEUE)
  11. struct fdev {
  12. evloop_cb_t cb;
  13. void *arg;
  14. int fd;
  15. uint16_t flags;
  16. #ifdef EVLOOP_EPOLL
  17. int16_t index;
  18. #else
  19. int16_t rdidx;
  20. int16_t wridx;
  21. #endif
  22. };
  23. #elif defined(EVLOOP_POLL)
  24. struct fdev {
  25. int i;
  26. };
  27. #else
  28. #error No evloop method defined.
  29. #endif
  30. struct timeout {
  31. evloop_cb_t cb;
  32. void *arg;
  33. struct th_handle th;
  34. };
  35. int evloop_init(void);
  36. int evloop(void);
  37. int fdev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb,
  38. void *arg);
  39. int fdev_del(struct fdev *ev);
  40. int fdev_enable(struct fdev *ev, uint16_t flags);
  41. int fdev_disable(struct fdev *ev, uint16_t flags);
  42. void evtimer_init(struct timeout *, evloop_cb_t, void *);
  43. int evtimer_add(struct timeout *, struct timespec *);
  44. void evtimer_del(struct timeout *);
  45. void evtimers_run(void);
  46. struct timespec evtimer_delay(void);
  47. int evtimer_gettime(struct timespec *);
  48. #endif