diff options
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 0000000000..90db1cc62d --- /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 | ||
