author: Jeff Dike <jdike@addtoit.com> 2007-10-16 01:27:25 -0700
committer: Linus Torvalds <torvalds@woody.linux-foundation.org> 2007-10-16 09:43:08 -0700
commit: d2753a6d199791a6abc75d9f657e3457fe61705f
parent: 791a644a8d73a9b95515f074afbb3caa0a9964fa
Commit Summary:
Diffstat:
1 file changed, 13 insertions, 1 deletion
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 6ff3d98281ba..9ffc61ac8ed6 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -26,6 +26,21 @@ int set_interval(void)
return 0;
}
+int timer_one_shot(int ticks)
+{
+ unsigned long usec = ticks * 1000000 / UM_HZ;
+ unsigned long sec = usec / 1000000;
+ struct itimerval interval;
+
+ usec %= 1000000;
+ interval = ((struct itimerval) { { 0, 0 }, { sec, usec } });
+
+ if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1)
+ return -errno;
+
+ return 0;
+}
+
void disable_timer(void)
{
struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
@@ -74,7 +89,7 @@ unsigned long long os_nsecs(void)
struct timeval tv;
gettimeofday(&tv, NULL);
- return (unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000;
+ return timeval_to_ns(&tv);
}
void idle_sleep(int secs)