Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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
 
8
struct tvec_t_base_s;
9
 
10
struct timer_list {
11
        struct list_head entry;
12
        unsigned long expires;
13
 
14
        spinlock_t lock;
15
        unsigned long magic;
16
 
17
        void (*function)(unsigned long);
18
        unsigned long data;
19
 
20
        struct tvec_t_base_s *base;
21
};
22
 
23
#define TIMER_MAGIC     0x4b87ad6e
24
 
25
#define TIMER_INITIALIZER(_function, _expires, _data) {         \
26
                .function = (_function),                        \
27
                .expires = (_expires),                          \
28
                .data = (_data),                                \
29
                .base = NULL,                                   \
30
                .magic = TIMER_MAGIC,                           \
31
                .lock = SPIN_LOCK_UNLOCKED,                     \
32
        }
33
 
34
/***
35
 * init_timer - initialize a timer.
36
 * @timer: the timer to be initialized
37
 *
38
 * init_timer() must be done to a timer prior calling *any* of the
39
 * other timer functions.
40
 */
41
static inline void init_timer(struct timer_list * timer)
42
{
43
        timer->base = NULL;
44
        timer->magic = TIMER_MAGIC;
45
        spin_lock_init(&timer->lock);
46
}
47
 
48
/***
49
 * timer_pending - is a timer pending?
50
 * @timer: the timer in question
51
 *
52
 * timer_pending will tell whether a given timer is currently pending,
53
 * or not. Callers must ensure serialization wrt. other operations done
54
 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
55
 *
56
 * return value: 1 if the timer is pending, 0 if not.
57
 */
58
static inline int timer_pending(const struct timer_list * timer)
59
{
60
        return timer->base != NULL;
61
}
62
 
63
extern void add_timer_on(struct timer_list *timer, int cpu);
64
extern int del_timer(struct timer_list * timer);
65
extern int __mod_timer(struct timer_list *timer, unsigned long expires);
66
extern int mod_timer(struct timer_list *timer, unsigned long expires);
67
 
68
/***
69
 * add_timer - start a timer
70
 * @timer: the timer to be added
71
 *
72
 * The kernel will do a ->function(->data) callback from the
73
 * timer interrupt at the ->expired point in the future. The
74
 * current time is 'jiffies'.
75
 *
76
 * The timer's ->expired, ->function (and if the handler uses it, ->data)
77
 * fields must be set prior calling this function.
78
 *
79
 * Timers with an ->expired field in the past will be executed in the next
80
 * timer tick.
81
 */
82
static inline void add_timer(struct timer_list * timer)
83
{
84
        __mod_timer(timer, timer->expires);
85
}
86
 
87
#ifdef CONFIG_SMP
88
  extern int del_timer_sync(struct timer_list * timer);
89
#else
90
# define del_timer_sync(t) del_timer(t)
91
#endif
92
 
93
extern void init_timers(void);
94
extern void run_local_timers(void);
95
extern void it_real_fn(unsigned long);
96
 
97
#endif