4 #define LCR_FD_EXCEPT 4
6 #define MICRO_SECONDS 1000000LL
8 #define TIME_SMALLER(left, right) \
9 (((left)->tv_sec*MICRO_SECONDS+(left)->tv_usec) <= ((right)->tv_sec*MICRO_SECONDS+(right)->tv_usec))
12 struct lcr_fd *next; /* pointer to next element in list */
13 int inuse; /* if in use */
14 int fd; /* file descriptior if in use */
15 int when; /* select on what event */
16 int (*cb)(struct lcr_fd *fd, unsigned int what, void *instance, int index); /* callback */
21 #define register_fd(a, b, c, d, e) _register_fd(a, b, c, d, e, __func__);
22 int _register_fd(struct lcr_fd *fd, int when, int (*cb)(struct lcr_fd *fd, unsigned int what, void *instance, int index), void *instance, int index, const char *func);
23 #define unregister_fd(a) _unregister_fd(a, __func__);
24 void _unregister_fd(struct lcr_fd *fd, const char *func);
25 int select_main(int polling, int *global_change, void (*lock)(void), void (*unlock)(void));
29 struct lcr_timer *next; /* pointer to next element in list */
30 int inuse; /* if in use */
31 int active; /* if timer is currently active */
32 struct timeval timeout; /* timestamp when to timeout */
33 int (*cb)(struct lcr_timer *timer, void *instance, int index); /* callback */
38 #define add_timer(a, b, c, d) _add_timer(a, b, c, d, __func__);
39 int _add_timer(struct lcr_timer *timer, int (*cb)(struct lcr_timer *timer, void *instance, int index), void *instance, int index, const char *func);
40 #define del_timer(a) _del_timer(a, __func__);
41 void _del_timer(struct lcr_timer *timer, const char *func);
42 void schedule_timer(struct lcr_timer *timer, int seconds, int microseconds);
43 void unsched_timer(struct lcr_timer *timer);
47 struct lcr_work *next; /* pointer to next element in list */
48 struct lcr_work *prev_event, *next_event; /* pointer to previous/next event, if triggered */
49 int inuse; /* if in use */
50 int active; /* if timer is currently active */
51 int (*cb)(struct lcr_work *work, void *instance, int index); /* callback */
56 #define add_work(a, b, c, d) _add_work(a, b, c, d, __func__);
57 int _add_work(struct lcr_work *work, int (*cb)(struct lcr_work *work, void *instance, int index), void *instance, int index, const char *func);
58 #define del_work(a) _del_work(a, __func__);
59 void _del_work(struct lcr_work *work, const char *func);
60 void trigger_work(struct lcr_work *work);