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

Re: [UNIKRAFT PATCH 3/5] lib/uktime: Register `gettimeofday` to syscall_shim



This should use the UK_SYSCALL_R_DEFINE macro, with the new

updated version it should support __unused so no warning will appear.


Reviewed-by: Daniel Dinca <dincadaniel97@xxxxxxxxx>

On 17.07.2020 15:47, Constantin Raducanu wrote:
Registers `gettimeofday` system call to syscall_shim library.
In order to avoid the unused warning for the second parameter,
I had to provide all three system call entry functions manually.

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

diff --git a/lib/uktime/Makefile.uk b/lib/uktime/Makefile.uk
index 2976a10..4fdf282 100644
--- a/lib/uktime/Makefile.uk
+++ b/lib/uktime/Makefile.uk
@@ -12,3 +12,5 @@ LIBUKTIME_SRCS-y += 
$(LIBUKTIME_BASE)/musl-imported/src/__tm_to_secs.c
  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
diff --git a/lib/uktime/exportsyms.uk b/lib/uktime/exportsyms.uk
index 82b70b7..90ad7f9 100644
--- a/lib/uktime/exportsyms.uk
+++ b/lib/uktime/exportsyms.uk
@@ -2,6 +2,8 @@ clock_getres
  clock_gettime
  clock_settime
  gettimeofday
+uk_syscall_e_gettimeofday
+uk_syscall_r_gettimeofday
  nanosleep
  setitimer
  sleep
diff --git a/lib/uktime/time.c b/lib/uktime/time.c
index 4d3ba53..e45b6f4 100644
--- a/lib/uktime/time.c
+++ b/lib/uktime/time.c
@@ -43,6 +43,8 @@
  #include <uk/plat/time.h>
  #include <uk/config.h>
  #include <uk/print.h>
+#include <uk/syscall.h>
+
  #if CONFIG_HAVE_SCHED
  #include <uk/sched.h>
  #else
@@ -125,20 +127,40 @@ unsigned int sleep(unsigned int seconds)
        return 0;
  }
-int gettimeofday(struct timeval *tv, void *tz __unused)
+long uk_syscall_r_gettimeofday(long tv, long tz __unused)
  {
        __nsec now = ukplat_wall_clock();
if (!tv) {
-               errno = EINVAL;
-               return -1;
+               return -EINVAL;
        }
- tv->tv_sec = ukarch_time_nsec_to_sec(now);
-       tv->tv_usec = ukarch_time_nsec_to_usec(ukarch_time_subsec(now));
+       ((struct timeval*) tv)->tv_sec = ukarch_time_nsec_to_sec(now);
+       ((struct timeval*) tv)->tv_usec =
+               ukarch_time_nsec_to_usec(ukarch_time_subsec(now));
+
        return 0;
  }
+long uk_syscall_e_gettimeofday(long tv, long tz __unused)
+{
+       long ret;
+
+       ret = uk_syscall_r_gettimeofday(tv, tz);
+       if (ret < 0) {
+               errno = (int) -ret;
+               return -1;
+       }
+       return 0;
+}
+
+#if !UK_LIBC_SYSCALL
+int gettimeofday (struct timeval* tv, void* tz __unused)
+{
+       return uk_syscall_e_gettimeofday((long) tv, (long)tz);
+}
+#endif
+
  int clock_getres(clockid_t clk_id __unused, struct timespec *res __unused)
  {
        return 0;




 


Rackspace

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