4 #include <linux/config.h>
5 #include <linux/list.h>
6 #include <linux/spinlock.h>
7 #include <linux/stddef.h>
12 struct list_head entry
;
13 unsigned long expires
;
18 void (*function
)(unsigned long);
21 struct tvec_t_base_s
*base
;
24 #define TIMER_MAGIC 0x4b87ad6e
26 #define TIMER_INITIALIZER(_function, _expires, _data) { \
27 .function = (_function), \
28 .expires = (_expires), \
31 .magic = TIMER_MAGIC, \
32 .lock = SPIN_LOCK_UNLOCKED, \
36 * init_timer - initialize a timer.
37 * @timer: the timer to be initialized
39 * init_timer() must be done to a timer prior calling *any* of the
40 * other timer functions.
42 static inline void init_timer(struct timer_list
* timer
)
45 timer
->magic
= TIMER_MAGIC
;
46 spin_lock_init(&timer
->lock
);
50 * timer_pending - is a timer pending?
51 * @timer: the timer in question
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.
57 * return value: 1 if the timer is pending, 0 if not.
59 static inline int timer_pending(const struct timer_list
* timer
)
61 return timer
->base
!= NULL
;
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
);
69 extern unsigned long next_timer_interrupt(void);
72 * add_timer - start a timer
73 * @timer: the timer to be added
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'.
79 * The timer's ->expired, ->function (and if the handler uses it, ->data)
80 * fields must be set prior calling this function.
82 * Timers with an ->expired field in the past will be executed in the next
85 static inline void add_timer(struct timer_list
* timer
)
87 __mod_timer(timer
, timer
->expires
);
91 extern int del_timer_sync(struct timer_list
*timer
);
92 extern int del_singleshot_timer_sync(struct timer_list
*timer
);
94 # define del_timer_sync(t) del_timer(t)
95 # define del_singleshot_timer_sync(t) del_timer(t)
98 extern void init_timers(void);
99 extern void run_local_timers(void);
100 extern void it_real_fn(unsigned long);