From: Ian Jackson Date: Sun, 24 May 2020 17:15:21 +0000 (+0100) Subject: regress: redirect clock_gettime X-Git-Tag: adns-1.6.0~8 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=commitdiff_plain;h=f5b6d7042f5e5f4b0df2cf96b60d9e47f5f03a50 regress: redirect clock_gettime This will let us test it. Signed-off-by: Ian Jackson --- diff --git a/regress/hcommon.c.m4 b/regress/hcommon.c.m4 index f3c77d9..74811a7 100644 --- a/regress/hcommon.c.m4 +++ b/regress/hcommon.c.m4 @@ -36,6 +36,7 @@ m4_include(hmacros.i4) #include #include +#include #include "harness.h" #include "internal.h" @@ -75,6 +76,17 @@ int Hgettimeofday(struct timeval *tv, struct timezone *tz) { *tv= currenttime; return 0; } +int Hclock_gettime(clockid_t clk, struct timespec *ts) { + Tensuresetup(); + ts->tv_sec = currenttime.tv_sec; + ts->tv_nsec = currenttime.tv_usec * 1000 + 666; + switch (clk) { + case CLOCK_MONOTONIC: ts->tv_sec -= 1500000000; break; + case CLOCK_REALTIME: break; + default: Tmust("clock_gettime","clk",0); + } + return 0; +} int Hwritev(int fd, const struct iovec *vector, size_t count) { size_t i; diff --git a/regress/hsyscalls.i4 b/regress/hsyscalls.i4 index fc76fd1..dbc584f 100644 --- a/regress/hsyscalls.i4 +++ b/regress/hsyscalls.i4 @@ -133,6 +133,7 @@ hm_syscall( hm_specsyscall(int, writev, `int fd, const struct iovec *vector, size_t count') hm_specsyscall(int, gettimeofday, `struct timeval *tv, struct timezone *tz') +hm_specsyscall(int, clock_gettime, `clockid_t clk, struct timespec *ts') hm_specsyscall(pid_t, getpid, `void') hm_specsyscall(int, close, `int fd')