From 1a5248bb177242a34fd51efadb4af941853d5e35 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 21 Apr 2022 19:38:45 +0300 Subject: use uint64_t for timer ticks + GCC seems to provide this even on 32bit platforms, though I should really check. --- common/uapi/timers.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'common/uapi/timers.c') diff --git a/common/uapi/timers.c b/common/uapi/timers.c index 1dfc8bf..66f6533 100644 --- a/common/uapi/timers.c +++ b/common/uapi/timers.c @@ -1,13 +1,32 @@ +#include #include -SYSCALL_DEFINE1(req_timer)(vm_t ticks) +static ticks_t scaled_ticks(vm_t ticks, vm_t repeat) { - /* TODO */ - return 0; +#if __WORDSIZE == 64 + UNUSED(repeat); + return ticks; +#else + return ((ticks_t)ticks << 32) + repeat; +#endif +} + +SYSCALL_DEFINE2(req_rel_timer)(vm_t ticks, vm_t repeat) +{ + return new_rel_timer(cur_tcb()->tid, scaled_ticks(ticks, repeat)); +} + +SYSCALL_DEFINE2(req_abs_timer)(vm_t ticks, vm_t repeat) +{ + return new_abs_timer(cur_tcb()->tid, scaled_ticks(ticks, repeat)); } SYSCALL_DEFINE1(free_timer)(vm_t cid) { - /* TODO */ - return 0; + struct timer *timer = find_timer(cid); + if (!timer) + return ERR_NF; + + remove_timer(timer); + return OK; } -- cgit v1.3