Import 2.3.25pre1
[davej-history.git] / include / linux / timer.h
blob796749fdba0ff266803c7f21bf3239f4285b2bac
1 #ifndef _LINUX_TIMER_H
2 #define _LINUX_TIMER_H
4 /*
5 * Old-style timers. Please don't use for any new code.
7 * Numbering of these timers should be consecutive to minimize
8 * processing delays. [MJ]
9 */
11 #define BLANK_TIMER 0 /* Console screen-saver */
12 #define BEEP_TIMER 1 /* Console beep */
13 #define RS_TIMER 2 /* RS-232 ports */
14 #define SWAP_TIMER 3 /* Background pageout */
15 #define BACKGR_TIMER 4 /* io_request background I/O */
16 #define HD_TIMER 5 /* Old IDE driver */
17 #define FLOPPY_TIMER 6 /* Floppy */
18 #define QIC02_TAPE_TIMER 7 /* QIC 02 tape */
19 #define MCD_TIMER 8 /* Mitsumi CDROM */
20 #define GSCD_TIMER 9 /* Goldstar CDROM */
21 #define COMTROL_TIMER 10 /* Comtrol serial */
22 #define DIGI_TIMER 11 /* Digi serial */
23 #define GDTH_TIMER 12 /* Ugh - gdth scsi driver */
25 #define COPRO_TIMER 31 /* 387 timeout for buggy hardware (boot only) */
27 struct timer_struct {
28 unsigned long expires;
29 void (*fn)(void);
32 extern unsigned long timer_active;
33 extern struct timer_struct timer_table[32];
36 * This is completely separate from the above, and is the
37 * "new and improved" way of handling timers more dynamically.
38 * Hopefully efficient and general enough for most things.
40 * The "hardcoded" timers above are still useful for well-
41 * defined problems, but the timer-list is probably better
42 * when you need multiple outstanding timers or similar.
44 * The "data" field is in case you want to use the same
45 * timeout function for several timeouts. You can use this
46 * to distinguish between the different invocations.
48 struct timer_list {
49 struct timer_list *next; /* MUST be first element */
50 struct timer_list *prev;
51 unsigned long expires;
52 unsigned long data;
53 void (*function)(unsigned long);
56 extern void add_timer(struct timer_list * timer);
57 extern int del_timer(struct timer_list * timer);
60 * mod_timer is a more efficient way to update the expire field of an
61 * active timer (if the timer is inactive it will be activated)
62 * mod_timer(a,b) is equivalent to del_timer(a); a->expires = b; add_timer(a)
64 void mod_timer(struct timer_list *timer, unsigned long expires);
66 extern void it_real_fn(unsigned long);
68 extern inline void init_timer(struct timer_list * timer)
70 timer->next = NULL;
71 timer->prev = NULL;
74 extern inline int timer_pending(const struct timer_list * timer)
76 return timer->prev != NULL;
80 * These inlines deal with timer wrapping correctly. You are
81 * strongly encouraged to use them
82 * 1. Because people otherwise forget
83 * 2. Because if the timer wrap changes in future you wont have to
84 * alter your driver code.
86 * Do this with "<0" and ">=0" to only test the sign of the result. A
87 * good compiler would generate better code (and a really good compiler
88 * wouldn't care). Gcc is currently neither.
90 #define time_after(a,b) ((long)(b) - (long)(a) < 0)
91 #define time_before(a,b) time_after(b,a)
93 #define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
94 #define time_before_eq(a,b) time_after_eq(b,a)
96 #endif