diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/timer.h |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/linux/timer.h')
-rw-r--r-- | include/linux/timer.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h new file mode 100644 index 000000000000..90db1cc62ddd --- /dev/null +++ b/include/linux/timer.h | |||
@@ -0,0 +1,102 @@ | |||
1 | #ifndef _LINUX_TIMER_H | ||
2 | #define _LINUX_TIMER_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | #include <linux/list.h> | ||
6 | #include <linux/spinlock.h> | ||
7 | #include <linux/stddef.h> | ||
8 | |||
9 | struct tvec_t_base_s; | ||
10 | |||
11 | struct timer_list { | ||
12 | struct list_head entry; | ||
13 | unsigned long expires; | ||
14 | |||
15 | spinlock_t lock; | ||
16 | unsigned long magic; | ||
17 | |||
18 | void (*function)(unsigned long); | ||
19 | unsigned long data; | ||
20 | |||
21 | struct tvec_t_base_s *base; | ||
22 | }; | ||
23 | |||
24 | #define TIMER_MAGIC 0x4b87ad6e | ||
25 | |||
26 | #define TIMER_INITIALIZER(_function, _expires, _data) { \ | ||
27 | .function = (_function), \ | ||
28 | .expires = (_expires), \ | ||
29 | .data = (_data), \ | ||
30 | .base = NULL, \ | ||
31 | .magic = TIMER_MAGIC, \ | ||
32 | .lock = SPIN_LOCK_UNLOCKED, \ | ||
33 | } | ||
34 | |||
35 | /*** | ||
36 | * init_timer - initialize a timer. | ||
37 | * @timer: the timer to be initialized | ||
38 | * | ||
39 | * init_timer() must be done to a timer prior calling *any* of the | ||
40 | * other timer functions. | ||
41 | */ | ||
42 | static inline void init_timer(struct timer_list * timer) | ||
43 | { | ||
44 | timer->base = NULL; | ||
45 | timer->magic = TIMER_MAGIC; | ||
46 | spin_lock_init(&timer->lock); | ||
47 | } | ||
48 | |||
49 | /*** | ||
50 | * timer_pending - is a timer pending? | ||
51 | * @timer: the timer in question | ||
52 | * | ||
53 | * timer_pending will tell whether a given timer is currently pending, | ||
54 | * or not. Callers must ensure serialization wrt. other operations done | ||
55 | * to this timer, eg. interrupt contexts, or other CPUs on SMP. | ||
56 | * | ||
57 | * return value: 1 if the timer is pending, 0 if not. | ||
58 | */ | ||
59 | static inline int timer_pending(const struct timer_list * timer) | ||
60 | { | ||
61 | return timer->base != NULL; | ||
62 | } | ||
63 | |||
64 | extern void add_timer_on(struct timer_list *timer, int cpu); | ||
65 | extern int del_timer(struct timer_list * timer); | ||
66 | extern int __mod_timer(struct timer_list *timer, unsigned long expires); | ||
67 | extern int mod_timer(struct timer_list *timer, unsigned long expires); | ||
68 | |||
69 | extern unsigned long next_timer_interrupt(void); | ||
70 | |||
71 | /*** | ||
72 | * add_timer - start a timer | ||
73 | * @timer: the timer to be added | ||
74 | * | ||
75 | * The kernel will do a ->function(->data) callback from the | ||
76 | * timer interrupt at the ->expired point in the future. The | ||
77 | * current time is 'jiffies'. | ||
78 | * | ||
79 | * The timer's ->expired, ->function (and if the handler uses it, ->data) | ||
80 | * fields must be set prior calling this function. | ||
81 | * | ||
82 | * Timers with an ->expired field in the past will be executed in the next | ||
83 | * timer tick. | ||
84 | */ | ||
85 | static inline void add_timer(struct timer_list * timer) | ||
86 | { | ||
87 | __mod_timer(timer, timer->expires); | ||
88 | } | ||
89 | |||
90 | #ifdef CONFIG_SMP | ||
91 | extern int del_timer_sync(struct timer_list *timer); | ||
92 | extern int del_singleshot_timer_sync(struct timer_list *timer); | ||
93 | #else | ||
94 | # define del_timer_sync(t) del_timer(t) | ||
95 | # define del_singleshot_timer_sync(t) del_timer(t) | ||
96 | #endif | ||
97 | |||
98 | extern void init_timers(void); | ||
99 | extern void run_local_timers(void); | ||
100 | extern void it_real_fn(unsigned long); | ||
101 | |||
102 | #endif | ||