x86: Add clock_adjtime for x86
[deliverable/linux.git] / include / linux / posix-timers.h
CommitLineData
1da177e4
LT
1#ifndef _linux_POSIX_TIMERS_H
2#define _linux_POSIX_TIMERS_H
3
4#include <linux/spinlock.h>
5#include <linux/list.h>
6#include <linux/sched.h>
f1f1d5eb 7#include <linux/timex.h>
1da177e4
LT
8
9union cpu_time_count {
10 cputime_t cpu;
11 unsigned long long sched;
12};
13
14struct cpu_timer_list {
15 struct list_head entry;
16 union cpu_time_count expires, incr;
17 struct task_struct *task;
18 int firing;
19};
20
21#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
22#define CPUCLOCK_PERTHREAD(clock) \
23 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
24#define CPUCLOCK_PID_MASK 7
25#define CPUCLOCK_PERTHREAD_MASK 4
26#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
27#define CPUCLOCK_CLOCK_MASK 3
28#define CPUCLOCK_PROF 0
29#define CPUCLOCK_VIRT 1
30#define CPUCLOCK_SCHED 2
31#define CPUCLOCK_MAX 3
32
33#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
34 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
35#define MAKE_THREAD_CPUCLOCK(tid, clock) \
36 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
37
38/* POSIX.1b interval timer structure. */
39struct k_itimer {
40 struct list_head list; /* free/ allocate list */
41 spinlock_t it_lock;
42 clockid_t it_clock; /* which timer type */
43 timer_t it_id; /* timer id */
44 int it_overrun; /* overrun on pending signal */
45 int it_overrun_last; /* overrun on last delivered signal */
2a698971 46 int it_requeue_pending; /* waiting to requeue this timer */
1da177e4
LT
47#define REQUEUE_PENDING 1
48 int it_sigev_notify; /* notify word of sigevent struct */
27af4245
ON
49 struct signal_struct *it_signal;
50 union {
51 struct pid *it_pid; /* pid of process to send signal to */
52 struct task_struct *it_process; /* for clock_nanosleep */
53 };
1da177e4
LT
54 struct sigqueue *sigq; /* signal queue entry. */
55 union {
56 struct {
becf8b5d
TG
57 struct hrtimer timer;
58 ktime_t interval;
1da177e4
LT
59 } real;
60 struct cpu_timer_list cpu;
61 struct {
62 unsigned int clock;
63 unsigned int node;
64 unsigned long incr;
65 unsigned long expires;
66 } mmtimer;
67 } it;
68};
69
1da177e4 70struct k_clock {
a924b04d 71 int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
1e6d7679
RC
72 int (*clock_set) (const clockid_t which_clock,
73 const struct timespec *tp);
a924b04d 74 int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
f1f1d5eb 75 int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
1da177e4 76 int (*timer_create) (struct k_itimer *timer);
2a698971 77 int (*nsleep) (const clockid_t which_clock, int flags,
97735f25 78 struct timespec *, struct timespec __user *);
1711ef38 79 long (*nsleep_restart) (struct restart_block *restart_block);
1da177e4
LT
80 int (*timer_set) (struct k_itimer * timr, int flags,
81 struct itimerspec * new_setting,
82 struct itimerspec * old_setting);
83 int (*timer_del) (struct k_itimer * timr);
84#define TIMER_RETRY 1
85 void (*timer_get) (struct k_itimer * timr,
86 struct itimerspec * cur_setting);
87};
88
1976945e
TG
89extern struct k_clock clock_posix_cpu;
90
a924b04d 91void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
1da177e4 92
1da177e4
LT
93/* function to call to trigger timer event */
94int posix_timer_event(struct k_itimer *timr, int si_private);
95
2a698971
TG
96void posix_cpu_timer_schedule(struct k_itimer *timer);
97
98void run_posix_cpu_timers(struct task_struct *task);
99void posix_cpu_timers_exit(struct task_struct *task);
100void posix_cpu_timers_exit_group(struct task_struct *task);
101
102void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
103 cputime_t *newval, cputime_t *oldval);
1da177e4 104
1711ef38
TA
105long clock_nanosleep_restart(struct restart_block *restart_block);
106
5ab46b34 107void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
f06febc9 108
1da177e4 109#endif
This page took 0.805859 seconds and 5 git commands to generate.