VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / posix-timers.h
1 #ifndef _linux_POSIX_TIMERS_H
2 #define _linux_POSIX_TIMERS_H
3
4 #include <linux/spinlock.h>
5 #include <linux/list.h>
6
7 struct k_clock_abs {
8         struct list_head list;
9         spinlock_t lock;
10 };
11 struct k_clock {
12         int res;                /* in nano seconds */
13         struct k_clock_abs *abs_struct;
14         int (*clock_set) (struct timespec * tp);
15         int (*clock_get) (struct timespec * tp);
16         int (*nsleep) (int flags,
17                        struct timespec * new_setting,
18                        struct itimerspec * old_setting);
19         int (*timer_set) (struct k_itimer * timr, int flags,
20                           struct itimerspec * new_setting,
21                           struct itimerspec * old_setting);
22         int (*timer_del) (struct k_itimer * timr);
23         void (*timer_get) (struct k_itimer * timr,
24                            struct itimerspec * cur_setting);
25 };
26 struct now_struct {
27         unsigned long jiffies;
28 };
29
30 #define posix_get_now(now) (now)->jiffies = jiffies;
31 #define posix_time_before(timer, now) \
32                       time_before((timer)->expires, (now)->jiffies)
33
34 #define posix_bump_timer(timr, now)                                     \
35          do {                                                           \
36               long delta, orun;                                         \
37               delta = now.jiffies - (timr)->it_timer.expires;           \
38               if (delta >= 0) {                                         \
39                    orun = 1 + (delta / (timr)->it_incr);                \
40                   (timr)->it_timer.expires += orun * (timr)->it_incr;   \
41                   (timr)->it_overrun += orun;                           \
42               }                                                         \
43             }while (0)
44 #endif