12 #include <linux/time.h>
14 #include <linux/hrtimer.h>
17 #include <asm/uaccess.h>
36 if (hrtimer_active(
timer)) {
42 return ktime_to_timeval(rem);
45 static void get_cpu_itimer(
struct task_struct *tsk,
unsigned int clock_id,
51 spin_lock_irq(&tsk->
sighand->siglock);
61 t = cputime.utime + cputime.stime;
73 spin_unlock_irq(&tsk->
sighand->siglock);
85 spin_lock_irq(&tsk->
sighand->siglock);
88 ktime_to_timeval(tsk->
signal->it_real_incr);
89 spin_unlock_irq(&tsk->
sighand->siglock);
138 cpu_ns = timespec_to_ns(&
ts);
140 return (cpu_ns <= real_ns) ? 0 : cpu_ns - real_ns;
143 static void set_cpu_itimer(
struct task_struct *tsk,
unsigned int clock_id,
147 cputime_t cval, nval, cinterval, ninterval;
148 s64 ns_ninterval, ns_nval;
153 ns_nval = timeval_to_ns(&value->
it_value);
157 error = cputime_sub_ns(nval, ns_nval);
158 incr_error = cputime_sub_ns(ninterval, ns_ninterval);
160 spin_lock_irq(&tsk->
sighand->siglock);
163 cinterval = it->
incr;
170 it->
incr = ninterval;
176 spin_unlock_irq(&tsk->
sighand->siglock);
187 #define timeval_valid(t) \
188 (((t)->tv_sec >= 0) && (((unsigned long) (t)->tv_usec) < USEC_PER_SEC))
206 spin_lock_irq(&tsk->
sighand->siglock);
207 timer = &tsk->
signal->real_timer;
209 ovalue->
it_value = itimer_get_remtime(timer);
211 = ktime_to_timeval(tsk->
signal->it_real_incr);
215 spin_unlock_irq(&tsk->
sighand->siglock);
218 expires = timeval_to_ktime(value->
it_value);
219 if (expires.
tv64 != 0) {
220 tsk->
signal->it_real_incr =
224 tsk->
signal->it_real_incr.tv64 = 0;
227 spin_unlock_irq(&tsk->
sighand->siglock);
257 #if BITS_PER_LONG < 64
288 memset(&set_buffer, 0,
sizeof(set_buffer));
290 " Misfeature support will be removed\n",
295 if (error || !ovalue)
298 if (
copy_to_user(ovalue, &get_buffer,
sizeof(get_buffer)))