chiark / gitweb /
regress: redirect clock_gettime
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 May 2020 17:15:21 +0000 (18:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Jun 2020 15:13:02 +0000 (16:13 +0100)
This will let us test it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/hcommon.c.m4
regress/hsyscalls.i4

index f3c77d9..74811a7 100644 (file)
@@ -36,6 +36,7 @@ m4_include(hmacros.i4)
 
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
 
 #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;
index fc76fd1..dbc584f 100644 (file)
@@ -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')