chiark / gitweb /
regress: Make arrangements for fuzzraw of gettimeofday
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Nov 2016 10:47:33 +0000 (10:47 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Jun 2020 15:13:02 +0000 (16:13 +0100)
Provide a hook to call in Hgettimeofday which is a stub in all but
fuzzraw.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/harness.h.m4
regress/hcommon.c.m4
regress/hfuzzraw.c.m4
regress/hplayback.c.m4
regress/hrecord.c.m4

index 65c0ba68778a0dabca2a740c613c211d535d639a..9d95778fa1960cb55448bbec8fc93db81abcfe90 100644 (file)
@@ -77,5 +77,6 @@ void Texit(int rv) NONRETURNING;
 void Tcommonshutdown(void);
 void Tmallocshutdown(void);
 int Ttestinputfd(void);
+void T_gettimeofday_hook(void);
 
 #endif
index a20ee178052d9f41d5ce21524bd6d1a56c122f82..3a700108410b5d897e12a104f9d8e9c100b6c54d 100644 (file)
@@ -71,6 +71,7 @@ static vbuf vbw;
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
   Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
+  T_gettimeofday_hook();
   *tv= currenttime;
   return 0;
 }
index c9c24ce3fe04fc2a577b1b5d46ebf46f8149700b..24aff421d8c97bda8b1e7f1c174dd23c919f8f4c 100644 (file)
@@ -85,15 +85,18 @@ static void P_read(void *p, size_t sz) {
 
 #define P_READ(x) (P_read(&(x), sizeof((x))))
 
-static void P_updatetime(void) {
-m4_dnl xxx
-}
-
 static unsigned P_fdf(int fd) {
   assert(fd>=0 && fd<fdtab.used);
   return fdtab.buf[fd];
 }
 
+void T_gettimeofday_hook(void) {
+  struct timeval delta, sum;
+  P_READ(delta);
+  timeradd(&delta, &currenttime, &sum);
+  currenttime= sum;
+}
+
 static void Paddr(struct sockaddr *addr, int *lenr) {
   int l, r;
   uint16_t port;
@@ -167,7 +170,6 @@ int H$1(hm_args_massage($3,void)) {
  $3
 
  Tensurerecordfile();
- P_updatetime();
 
  m4_define(`hm_rv_succfail',`
   P_READ(r);
@@ -237,7 +239,6 @@ int H$1(hm_args_massage($3,void)) {
  m4_define(`hm_arg_bytes_out',`r= Pbytes($'`2,$'`4);')
  $3
 
- P_updatetime();
  return r;
 }
 ')
index 547dfe4efc43483ce137f776ab570c7b1fe8fcbd..f63319dcb4998288da1c3b6febc870bbfe9f4583 100644 (file)
@@ -70,6 +70,8 @@ static void Pcheckinput(void) {
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
 
+void T_gettimeofday_hook(void) { }
+
 void Tensurerecordfile(void) {
   int fd;
   int chars;
index f23df33a8960634b2a13c789901a2b11fd32dace..20764237e0d5817d34ddf4f39aee2a9cc973c12f 100644 (file)
@@ -53,6 +53,8 @@ static void R_recordtime(void) {
   currenttime= tv;
 }
 
+void T_gettimeofday_hook(void) { }
+
 void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;