| 1 | #ifndef _linux_POSIX_TIMERS_H |
|---|
| 2 | #define _linux_POSIX_TIMERS_H |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | struct k_clock { |
|---|
| 6 | int res; /* in nano seconds */ |
|---|
| 7 | int (*clock_getres) (clockid_t which_clock, struct timespec *tp); |
|---|
| 8 | struct k_clock_abs *abs_struct; |
|---|
| 9 | int (*clock_set) (clockid_t which_clock, struct timespec * tp); |
|---|
| 10 | int (*clock_get) (clockid_t which_clock, struct timespec * tp); |
|---|
| 11 | int (*timer_create) (struct k_itimer *timer); |
|---|
| 12 | int (*nsleep) (clockid_t which_clock, int flags, struct timespec *); |
|---|
| 13 | int (*timer_set) (struct k_itimer * timr, int flags, |
|---|
| 14 | struct itimerspec * new_setting, |
|---|
| 15 | struct itimerspec * old_setting); |
|---|
| 16 | int (*timer_del) (struct k_itimer * timr); |
|---|
| 17 | #define TIMER_RETRY 1 |
|---|
| 18 | void (*timer_get) (struct k_itimer * timr, |
|---|
| 19 | struct itimerspec * cur_setting); |
|---|
| 20 | }; |
|---|
| 21 | |
|---|
| 22 | void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock); |
|---|
| 23 | |
|---|
| 24 | /* Error handlers for timer_create, nanosleep and settime */ |
|---|
| 25 | int do_posix_clock_notimer_create(struct k_itimer *timer); |
|---|
| 26 | int do_posix_clock_nonanosleep(clockid_t, int flags, struct timespec *); |
|---|
| 27 | int do_posix_clock_nosettime(clockid_t, struct timespec *tp); |
|---|
| 28 | |
|---|
| 29 | /* function to call to trigger timer event */ |
|---|
| 30 | int posix_timer_event(struct k_itimer *timr, int si_private); |
|---|
| 31 | |
|---|
| 32 | struct now_struct { |
|---|
| 33 | unsigned long jiffies; |
|---|
| 34 | }; |
|---|
| 35 | |
|---|
| 36 | #define posix_get_now(now) (now)->jiffies = jiffies; |
|---|
| 37 | #define posix_time_before(timer, now) \ |
|---|
| 38 | time_before((timer)->expires, (now)->jiffies) |
|---|
| 39 | |
|---|
| 40 | #define posix_bump_timer(timr, now) \ |
|---|
| 41 | do { \ |
|---|
| 42 | long delta, orun; \ |
|---|
| 43 | delta = now.jiffies - (timr)->it.real.timer.expires; \ |
|---|
| 44 | if (delta >= 0) { \ |
|---|
| 45 | orun = 1 + (delta / (timr)->it.real.incr); \ |
|---|
| 46 | (timr)->it.real.timer.expires += \ |
|---|
| 47 | orun * (timr)->it.real.incr; \ |
|---|
| 48 | (timr)->it_overrun += orun; \ |
|---|
| 49 | } \ |
|---|
| 50 | }while (0) |
|---|
| 51 | |
|---|
| 52 | int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *); |
|---|
| 53 | int posix_cpu_clock_get(clockid_t which_clock, struct timespec *); |
|---|
| 54 | int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp); |
|---|
| 55 | int posix_cpu_timer_create(struct k_itimer *); |
|---|
| 56 | int posix_cpu_nsleep(clockid_t, int, struct timespec *); |
|---|
| 57 | int posix_cpu_timer_set(struct k_itimer *, int, |
|---|
| 58 | struct itimerspec *, struct itimerspec *); |
|---|
| 59 | int posix_cpu_timer_del(struct k_itimer *); |
|---|
| 60 | void posix_cpu_timer_get(struct k_itimer *, struct itimerspec *); |
|---|
| 61 | |
|---|
| 62 | void posix_cpu_timer_schedule(struct k_itimer *); |
|---|
| 63 | |
|---|
| 64 | void run_posix_cpu_timers(struct task_struct *); |
|---|
| 65 | void posix_cpu_timers_exit(struct task_struct *); |
|---|
| 66 | void posix_cpu_timers_exit_group(struct task_struct *); |
|---|
| 67 | |
|---|
| 68 | void set_process_cpu_timer(struct task_struct *, unsigned int, |
|---|
| 69 | cputime_t *, cputime_t *); |
|---|
| 70 | |
|---|
| 71 | #endif |
|---|