summaryrefslogtreecommitdiffstats
path: root/kernel/itimer.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-01-04 16:03:48 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-01-04 16:03:48 +0000
commit78c388aed2b7184182c08428db1de6c872d815f5 (patch)
tree4b2003b1b4ceb241a17faa995da8dd1004bb8e45 /kernel/itimer.c
parenteb7a5bf93aaa4be1d7c6181100ab7639e74d67f7 (diff)
Merge with Linux 2.1.131 and more MIPS goodies.
(Did I mention that CVS is buggy ...)
Diffstat (limited to 'kernel/itimer.c')
-rw-r--r--kernel/itimer.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/kernel/itimer.c b/kernel/itimer.c
index d4bbf7851..1b4661c39 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -6,14 +6,9 @@
/* These are all the functions necessary to implement itimers */
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/time.h>
#include <linux/mm.h>
-#include <linux/smp.h>
#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <asm/uaccess.h>
@@ -53,15 +48,15 @@ int do_getitimer(int which, struct itimerval *value)
case ITIMER_REAL:
interval = current->it_real_incr;
val = 0;
- if (del_timer(&current->real_timer)) {
- unsigned long now = jiffies;
- val = current->real_timer.expires;
- add_timer(&current->real_timer);
+ start_bh_atomic();
+ if (timer_pending(&current->real_timer)) {
+ val = current->real_timer.expires - jiffies;
+
/* look out for negative/zero itimer.. */
- if (val <= now)
- val = now+1;
- val -= now;
+ if ((long) val <= 0)
+ val = 1;
}
+ end_bh_atomic();
break;
case ITIMER_VIRTUAL:
val = current->it_virt_value;
@@ -102,11 +97,9 @@ void it_real_fn(unsigned long __data)
send_sig(SIGALRM, p, 1);
interval = p->it_real_incr;
if (interval) {
- unsigned long timeout = jiffies + interval;
- /* check for overflow */
- if (timeout < interval)
- timeout = ULONG_MAX;
- p->real_timer.expires = timeout;
+ if (interval > (unsigned long) LONG_MAX)
+ interval = LONG_MAX;
+ p->real_timer.expires = jiffies + interval;
add_timer(&p->real_timer);
}
}
@@ -122,15 +115,16 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
return k;
switch (which) {
case ITIMER_REAL:
+ start_bh_atomic();
del_timer(&current->real_timer);
+ end_bh_atomic();
current->it_real_value = j;
current->it_real_incr = i;
if (!j)
break;
+ if (j > (unsigned long) LONG_MAX)
+ j = LONG_MAX;
i = j + jiffies;
- /* check for overflow.. */
- if (i < j)
- i = ULONG_MAX;
current->real_timer.expires = i;
add_timer(&current->real_timer);
break;