chiark / gitweb /
regress: redirect clock_gettime
[adns.git] / regress / hcommon.c.m4
index f3c77d9de1e55263d91e9d926dbd7ba0be4696e3..74811a73e32807f1284aaeb57857ee7b637ae0c5 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;