]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/linux/posix-timers.h
posix-timers: Move the do_schedule_next_timer declaration
[karo-tx-linux.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 #include <linux/sched.h>
7 #include <linux/timex.h>
8 #include <linux/alarmtimer.h>
9
10 struct siginfo;
11
12 struct cpu_timer_list {
13         struct list_head entry;
14         u64 expires, incr;
15         struct task_struct *task;
16         int firing;
17 };
18
19 /*
20  * Bit fields within a clockid:
21  *
22  * The most significant 29 bits hold either a pid or a file descriptor.
23  *
24  * Bit 2 indicates whether a cpu clock refers to a thread or a process.
25  *
26  * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
27  *
28  * A clockid is invalid if bits 2, 1, and 0 are all set.
29  */
30 #define CPUCLOCK_PID(clock)             ((pid_t) ~((clock) >> 3))
31 #define CPUCLOCK_PERTHREAD(clock) \
32         (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
33
34 #define CPUCLOCK_PERTHREAD_MASK 4
35 #define CPUCLOCK_WHICH(clock)   ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
36 #define CPUCLOCK_CLOCK_MASK     3
37 #define CPUCLOCK_PROF           0
38 #define CPUCLOCK_VIRT           1
39 #define CPUCLOCK_SCHED          2
40 #define CPUCLOCK_MAX            3
41 #define CLOCKFD                 CPUCLOCK_MAX
42 #define CLOCKFD_MASK            (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
43
44 #define MAKE_PROCESS_CPUCLOCK(pid, clock) \
45         ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
46 #define MAKE_THREAD_CPUCLOCK(tid, clock) \
47         MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
48
49 #define FD_TO_CLOCKID(fd)       ((~(clockid_t) (fd) << 3) | CLOCKFD)
50 #define CLOCKID_TO_FD(clk)      ((unsigned int) ~((clk) >> 3))
51
52 /* POSIX.1b interval timer structure. */
53 struct k_itimer {
54         struct list_head list;          /* free/ allocate list */
55         struct hlist_node t_hash;
56         spinlock_t it_lock;
57         clockid_t it_clock;             /* which timer type */
58         timer_t it_id;                  /* timer id */
59         int it_overrun;                 /* overrun on pending signal  */
60         int it_overrun_last;            /* overrun on last delivered signal */
61         int it_requeue_pending;         /* waiting to requeue this timer */
62 #define REQUEUE_PENDING 1
63         int it_sigev_notify;            /* notify word of sigevent struct */
64         struct signal_struct *it_signal;
65         union {
66                 struct pid *it_pid;     /* pid of process to send signal to */
67                 struct task_struct *it_process; /* for clock_nanosleep */
68         };
69         struct sigqueue *sigq;          /* signal queue entry. */
70         union {
71                 struct {
72                         struct hrtimer timer;
73                         ktime_t interval;
74                 } real;
75                 struct cpu_timer_list cpu;
76                 struct {
77                         struct alarm alarmtimer;
78                         ktime_t interval;
79                 } alarm;
80                 struct rcu_head rcu;
81         } it;
82 };
83
84 struct k_clock {
85         int (*clock_getres) (const clockid_t which_clock, struct timespec64 *tp);
86         int (*clock_set) (const clockid_t which_clock,
87                           const struct timespec64 *tp);
88         int (*clock_get) (const clockid_t which_clock, struct timespec64 *tp);
89         int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
90         int (*timer_create) (struct k_itimer *timer);
91         int (*nsleep) (const clockid_t which_clock, int flags,
92                        struct timespec64 *, struct timespec __user *);
93         long (*nsleep_restart) (struct restart_block *restart_block);
94         int (*timer_set) (struct k_itimer *timr, int flags,
95                           struct itimerspec64 *new_setting,
96                           struct itimerspec64 *old_setting);
97         int (*timer_del) (struct k_itimer *timr);
98 #define TIMER_RETRY 1
99         void (*timer_get) (struct k_itimer *timr,
100                            struct itimerspec64 *cur_setting);
101 };
102
103 extern const struct k_clock clock_posix_cpu;
104 extern const struct k_clock clock_posix_dynamic;
105 extern const struct k_clock clock_process;
106 extern const struct k_clock clock_thread;
107 extern const struct k_clock alarm_clock;
108
109 /* function to call to trigger timer event */
110 int posix_timer_event(struct k_itimer *timr, int si_private);
111
112 void posix_cpu_timer_schedule(struct k_itimer *timer);
113
114 void run_posix_cpu_timers(struct task_struct *task);
115 void posix_cpu_timers_exit(struct task_struct *task);
116 void posix_cpu_timers_exit_group(struct task_struct *task);
117 void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
118                            u64 *newval, u64 *oldval);
119
120 long clock_nanosleep_restart(struct restart_block *restart_block);
121
122 void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
123
124 void do_schedule_next_timer(struct siginfo *info);
125
126 #endif