summaryrefslogtreecommitdiffstats
path: root/system/csh/timespec.diff
blob: 3877be355dfd46113064fc9d88a71938a5daaed4 (plain)
diff -Naur csh-20230828/extern.h csh-20230828.patched/extern.h
--- csh-20230828/extern.h	2023-09-19 17:44:07.356219253 -0400
+++ csh-20230828.patched/extern.h	2023-09-19 18:07:32.732605839 -0400
@@ -276,6 +276,7 @@
 void	settimes(void);
 void	pcsecs(long);
 void	psecs(long);
+int	timespec_gettimeofday(struct timespec *restrict, struct timezone *restrict);
 
 /*
  * alloc.c
diff -Naur csh-20230828/proc.c csh-20230828.patched/proc.c
--- csh-20230828/proc.c	2023-09-19 17:44:07.349219157 -0400
+++ csh-20230828.patched/proc.c	2023-09-19 18:06:05.785406431 -0400
@@ -121,7 +121,7 @@
     }
     else {
 	if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
-	  (void) gettimeofday(&pp->p_etime, NULL);
+	  (void) timespec_gettimeofday(&pp->p_etime, NULL);
 
 
 	pp->p_rusage = ru;
@@ -507,7 +507,7 @@
     }
     pp->p_next = proclist.p_next;
     proclist.p_next = pp;
-    (void) gettimeofday(&pp->p_btime, NULL);
+    (void) timespec_gettimeofday(&pp->p_btime, NULL);
 
 }
 
diff -Naur csh-20230828/time.c csh-20230828.patched/time.c
--- csh-20230828/time.c	2023-09-19 17:44:07.350219170 -0400
+++ csh-20230828.patched/time.c	2023-09-19 18:08:07.012078715 -0400
@@ -30,6 +30,7 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <stdarg.h>
 
@@ -39,6 +40,20 @@
 /*
  * C Shell - routines handling process timing and niceing
  */
+
+int
+timespec_gettimeofday(struct timespec *restrict ts, struct timezone *restrict)
+{
+    int rv;
+    struct timeval tv;
+
+    rv = gettimeofday(&tv, NULL);
+    ts->tv_sec = tv.tv_sec;
+    ts->tv_nsec = tv.tv_usec * 1000;
+
+    return rv;
+}
+
 static void	pdeltat(struct timeval *, struct timeval *);
 
 void
@@ -46,7 +61,7 @@
 {
     struct rusage ruch;
 
-    (void) gettimeofday(&time0, NULL);
+    (void) timespec_gettimeofday(&time0, NULL);
     (void) getrusage(RUSAGE_SELF, &ru0);
     (void) getrusage(RUSAGE_CHILDREN, &ruch);
     ruadd(&ru0, &ruch);
@@ -65,7 +80,7 @@
     (void) getrusage(RUSAGE_SELF, &ru1);
     (void) getrusage(RUSAGE_CHILDREN, &ruch);
     ruadd(&ru1, &ruch);
-    (void) gettimeofday(&timedol, NULL);
+    (void) timespec_gettimeofday(&timedol, NULL);
     prusage(&ru0, &ru1, &timedol, &time0);
 }