]> git.sesse.net Git - bcachefs-tools-debian/blob - c_src/include/linux/timer.h
9667acf9d70a7694c40ca4e38537a3db79efd7f5
[bcachefs-tools-debian] / c_src / include / linux / timer.h
1 #ifndef __TOOLS_LINUX_TIMER_H
2 #define __TOOLS_LINUX_TIMER_H
3
4 #include <string.h>
5 #include <linux/types.h>
6
7 struct timer_list {
8         unsigned long           expires;
9         void                    (*function)(struct timer_list *timer);
10         bool                    pending;
11 };
12
13 static inline void timer_setup(struct timer_list *timer,
14                                void (*func)(struct timer_list *),
15                                unsigned int flags)
16 {
17         memset(timer, 0, sizeof(*timer));
18         timer->function = func;
19 }
20
21 #define timer_setup_on_stack(timer, callback, flags)                    \
22         timer_setup(timer, callback, flags)
23
24 #define destroy_timer_on_stack(timer) do {} while (0)
25
26 static inline int timer_pending(const struct timer_list *timer)
27 {
28         return timer->pending;
29 }
30
31 int del_timer(struct timer_list * timer);
32 int del_timer_sync(struct timer_list *timer);
33
34 #define del_singleshot_timer_sync(timer) del_timer_sync(timer)
35
36 int mod_timer(struct timer_list *timer, unsigned long expires);
37
38 static inline void add_timer(struct timer_list *timer)
39 {
40         BUG_ON(timer_pending(timer));
41         mod_timer(timer, timer->expires);
42 }
43
44 void flush_timers(void);
45
46 #endif /* __TOOLS_LINUX_TIMER_H */