[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH 4/5] lib/uktime: Register `clock_gettime` to syscall_shim



Registers `clock_gettime` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@xxxxxxxxx>
---
 lib/uktime/Makefile.uk   |  3 ++-
 lib/uktime/exportsyms.uk |  2 ++
 lib/uktime/time.c        | 15 ++++++++++-----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lib/uktime/Makefile.uk b/lib/uktime/Makefile.uk
index 4fdf282..fa29f72 100644
--- a/lib/uktime/Makefile.uk
+++ b/lib/uktime/Makefile.uk
@@ -13,4 +13,5 @@ LIBUKTIME_SRCS-y += 
$(LIBUKTIME_BASE)/musl-imported/src/__year_to_secs.c
 LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/time.c
 LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/timer.c
 
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKTIME) += gettimeofday-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKTIME) += gettimeofday-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKTIME) += clock_gettime-2
\ No newline at end of file
diff --git a/lib/uktime/exportsyms.uk b/lib/uktime/exportsyms.uk
index 90ad7f9..a79034a 100644
--- a/lib/uktime/exportsyms.uk
+++ b/lib/uktime/exportsyms.uk
@@ -1,5 +1,7 @@
 clock_getres
 clock_gettime
+uk_syscall_e_clock_gettime
+uk_syscall_r_clock_gettime
 clock_settime
 gettimeofday
 uk_syscall_e_gettimeofday
diff --git a/lib/uktime/time.c b/lib/uktime/time.c
index e45b6f4..2f1ee84 100644
--- a/lib/uktime/time.c
+++ b/lib/uktime/time.c
@@ -166,30 +166,35 @@ int clock_getres(clockid_t clk_id __unused, struct 
timespec *res __unused)
        return 0;
 }
 
-int clock_gettime(clockid_t clk_id __unused, struct timespec *tp __unused)
+UK_SYSCALL_R_DEFINE(int, clock_gettime, clockid_t, clk_id, struct timespec*, 
tp)
 {
        __nsec now;
+       int error;
 
        if (!tp) {
-               errno = EFAULT;
-               return -1;
+               error = EFAULT;
+               goto out_error;
        }
 
        switch (clk_id) {
        case CLOCK_MONOTONIC:
+       case CLOCK_MONOTONIC_COARSE:
                now = ukplat_monotonic_clock();
                break;
        case CLOCK_REALTIME:
                now = ukplat_wall_clock();
                break;
        default:
-               errno = EINVAL;
-               return -1;
+               error = EINVAL;
+               goto out_error;
        }
 
        tp->tv_sec = ukarch_time_nsec_to_sec(now);
        tp->tv_nsec = ukarch_time_subsec(now);
        return 0;
+
+out_error:
+       return -error;
 }
 
 int clock_settime(clockid_t clk_id __unused, const struct timespec *tp 
__unused)
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.