diff options
Diffstat (limited to 'arch/um/os-Linux/time.c')
-rw-r--r-- | arch/um/os-Linux/time.c | 17 |
1 files changed, 16 insertions, 1 deletions
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) |