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 f3c77d9de1e55263d91e9d926dbd7ba0be4696e3..74811a73e32807f1284aaeb57857ee7b637ae0c5 100644 (file)
@@ -36,6 +36,7 @@ m4_include(hmacros.i4)
 
 #include <unistd.h>
 #include <fcntl.h>
 
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
 
 #include "harness.h"
 #include "internal.h"
 
 #include "harness.h"
 #include "internal.h"
@@ -75,6 +76,17 @@ int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
   *tv= currenttime;
   return 0;
 }
   *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;
 
 int Hwritev(int fd, const struct iovec *vector, size_t count) {
   size_t i;
index fc76fd180c6213d8d2181a6133cc45020f7db7a9..dbc584f031ffb8f087eb1a03e99b6e70311ef960 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, 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')
 
 hm_specsyscall(pid_t, getpid, `void')
 hm_specsyscall(int, close, `int fd')