4 #include <linux/config.h>
5 #include <linux/list.h>
8 * This is completely separate from the above, and is the
9 * "new and improved" way of handling timers more dynamically.
10 * Hopefully efficient and general enough for most things.
12 * The "hardcoded" timers above are still useful for well-
13 * defined problems, but the timer-list is probably better
14 * when you need multiple outstanding timers or similar.
16 * The "data" field is in case you want to use the same
17 * timeout function for several timeouts. You can use this
18 * to distinguish between the different invocations.
21 struct list_head list
;
22 unsigned long expires
;
24 void (*function
)(unsigned long);
27 extern void add_timer(struct timer_list
* timer
);
28 extern int del_timer(struct timer_list
* timer
);
31 extern int del_timer_sync(struct timer_list
* timer
);
32 extern void sync_timers(void);
34 #define del_timer_sync(t) del_timer(t)
35 #define sync_timers() do { } while (0)
39 * mod_timer is a more efficient way to update the expire field of an
40 * active timer (if the timer is inactive it will be activated)
41 * mod_timer(a,b) is equivalent to del_timer(a); a->expires = b; add_timer(a).
42 * If the timer is known to be not pending (ie, in the handler), mod_timer
43 * is less efficient than a->expires = b; add_timer(a).
45 int mod_timer(struct timer_list
*timer
, unsigned long expires
);
47 extern void it_real_fn(unsigned long);
49 static inline void init_timer(struct timer_list
* timer
)
51 timer
->list
.next
= timer
->list
.prev
= NULL
;
54 static inline int timer_pending (const struct timer_list
* timer
)
56 return timer
->list
.next
!= NULL
;
60 * These inlines deal with timer wrapping correctly. You are
61 * strongly encouraged to use them
62 * 1. Because people otherwise forget
63 * 2. Because if the timer wrap changes in future you wont have to
64 * alter your driver code.
66 * Do this with "<0" and ">=0" to only test the sign of the result. A
67 * good compiler would generate better code (and a really good compiler
68 * wouldn't care). Gcc is currently neither.
70 #define time_after(a,b) ((long)(b) - (long)(a) < 0)
71 #define time_before(a,b) time_after(b,a)
73 #define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
74 #define time_before_eq(a,b) time_after_eq(b,a)