diff options
Diffstat (limited to 'include/linux/posix-timers.h')
| -rw-r--r-- | include/linux/posix-timers.h | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 3e23844a6990..d51243ae0726 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
| 5 | #include <linux/list.h> | 5 | #include <linux/list.h> |
| 6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 7 | #include <linux/timex.h> | ||
| 7 | 8 | ||
| 8 | union cpu_time_count { | 9 | union cpu_time_count { |
| 9 | cputime_t cpu; | 10 | cputime_t cpu; |
| @@ -17,10 +18,21 @@ struct cpu_timer_list { | |||
| 17 | int firing; | 18 | int firing; |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 21 | /* | ||
| 22 | * Bit fields within a clockid: | ||
| 23 | * | ||
| 24 | * The most significant 29 bits hold either a pid or a file descriptor. | ||
| 25 | * | ||
| 26 | * Bit 2 indicates whether a cpu clock refers to a thread or a process. | ||
| 27 | * | ||
| 28 | * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3. | ||
| 29 | * | ||
| 30 | * A clockid is invalid if bits 2, 1, and 0 are all set. | ||
| 31 | */ | ||
| 20 | #define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) | 32 | #define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) |
| 21 | #define CPUCLOCK_PERTHREAD(clock) \ | 33 | #define CPUCLOCK_PERTHREAD(clock) \ |
| 22 | (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) | 34 | (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) |
| 23 | #define CPUCLOCK_PID_MASK 7 | 35 | |
| 24 | #define CPUCLOCK_PERTHREAD_MASK 4 | 36 | #define CPUCLOCK_PERTHREAD_MASK 4 |
| 25 | #define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK) | 37 | #define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK) |
| 26 | #define CPUCLOCK_CLOCK_MASK 3 | 38 | #define CPUCLOCK_CLOCK_MASK 3 |
| @@ -28,12 +40,17 @@ struct cpu_timer_list { | |||
| 28 | #define CPUCLOCK_VIRT 1 | 40 | #define CPUCLOCK_VIRT 1 |
| 29 | #define CPUCLOCK_SCHED 2 | 41 | #define CPUCLOCK_SCHED 2 |
| 30 | #define CPUCLOCK_MAX 3 | 42 | #define CPUCLOCK_MAX 3 |
| 43 | #define CLOCKFD CPUCLOCK_MAX | ||
| 44 | #define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK) | ||
| 31 | 45 | ||
| 32 | #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ | 46 | #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ |
| 33 | ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) | 47 | ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) |
| 34 | #define MAKE_THREAD_CPUCLOCK(tid, clock) \ | 48 | #define MAKE_THREAD_CPUCLOCK(tid, clock) \ |
| 35 | MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK) | 49 | MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK) |
| 36 | 50 | ||
| 51 | #define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD) | ||
| 52 | #define CLOCKID_TO_FD(clk) ((unsigned int) ~((clk) >> 3)) | ||
| 53 | |||
| 37 | /* POSIX.1b interval timer structure. */ | 54 | /* POSIX.1b interval timer structure. */ |
| 38 | struct k_itimer { | 55 | struct k_itimer { |
| 39 | struct list_head list; /* free/ allocate list */ | 56 | struct list_head list; /* free/ allocate list */ |
| @@ -67,10 +84,11 @@ struct k_itimer { | |||
| 67 | }; | 84 | }; |
| 68 | 85 | ||
| 69 | struct k_clock { | 86 | struct k_clock { |
| 70 | int res; /* in nanoseconds */ | ||
| 71 | int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); | 87 | int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); |
| 72 | int (*clock_set) (const clockid_t which_clock, struct timespec * tp); | 88 | int (*clock_set) (const clockid_t which_clock, |
| 89 | const struct timespec *tp); | ||
| 73 | int (*clock_get) (const clockid_t which_clock, struct timespec * tp); | 90 | int (*clock_get) (const clockid_t which_clock, struct timespec * tp); |
| 91 | int (*clock_adj) (const clockid_t which_clock, struct timex *tx); | ||
| 74 | int (*timer_create) (struct k_itimer *timer); | 92 | int (*timer_create) (struct k_itimer *timer); |
| 75 | int (*nsleep) (const clockid_t which_clock, int flags, | 93 | int (*nsleep) (const clockid_t which_clock, int flags, |
| 76 | struct timespec *, struct timespec __user *); | 94 | struct timespec *, struct timespec __user *); |
| @@ -84,28 +102,14 @@ struct k_clock { | |||
| 84 | struct itimerspec * cur_setting); | 102 | struct itimerspec * cur_setting); |
| 85 | }; | 103 | }; |
| 86 | 104 | ||
| 87 | void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock); | 105 | extern struct k_clock clock_posix_cpu; |
| 106 | extern struct k_clock clock_posix_dynamic; | ||
| 88 | 107 | ||
| 89 | /* error handlers for timer_create, nanosleep and settime */ | 108 | void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock); |
| 90 | int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *, | ||
| 91 | struct timespec __user *); | ||
| 92 | int do_posix_clock_nosettime(const clockid_t, struct timespec *tp); | ||
| 93 | 109 | ||
| 94 | /* function to call to trigger timer event */ | 110 | /* function to call to trigger timer event */ |
| 95 | int posix_timer_event(struct k_itimer *timr, int si_private); | 111 | int posix_timer_event(struct k_itimer *timr, int si_private); |
| 96 | 112 | ||
| 97 | int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *ts); | ||
| 98 | int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *ts); | ||
| 99 | int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *ts); | ||
| 100 | int posix_cpu_timer_create(struct k_itimer *timer); | ||
| 101 | int posix_cpu_nsleep(const clockid_t which_clock, int flags, | ||
| 102 | struct timespec *rqtp, struct timespec __user *rmtp); | ||
| 103 | long posix_cpu_nsleep_restart(struct restart_block *restart_block); | ||
| 104 | int posix_cpu_timer_set(struct k_itimer *timer, int flags, | ||
| 105 | struct itimerspec *new, struct itimerspec *old); | ||
| 106 | int posix_cpu_timer_del(struct k_itimer *timer); | ||
| 107 | void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp); | ||
| 108 | |||
| 109 | void posix_cpu_timer_schedule(struct k_itimer *timer); | 113 | void posix_cpu_timer_schedule(struct k_itimer *timer); |
| 110 | 114 | ||
| 111 | void run_posix_cpu_timers(struct task_struct *task); | 115 | void run_posix_cpu_timers(struct task_struct *task); |
