aboutsummaryrefslogtreecommitdiff
path: root/arch/um/os-Linux/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/time.c')
-rw-r--r--arch/um/os-Linux/time.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 6ff3d98281b..9ffc61ac8ed 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)