Module Name:    src
Committed By:   christos
Date:           Wed Nov  9 19:16:01 UTC 2011

Modified Files:
        src/bin/csh: csh.h dol.c extern.h proc.c proc.h time.c

Log Message:
sync with /usr/bin/time, use CLOCK_MONOTONIC


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/bin/csh/csh.h
cvs rdiff -u -r1.27 -r1.28 src/bin/csh/dol.c
cvs rdiff -u -r1.23 -r1.24 src/bin/csh/extern.h
cvs rdiff -u -r1.34 -r1.35 src/bin/csh/proc.c
cvs rdiff -u -r1.12 -r1.13 src/bin/csh/proc.h
cvs rdiff -u -r1.18 -r1.19 src/bin/csh/time.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/csh/csh.h
diff -u src/bin/csh/csh.h:1.21 src/bin/csh/csh.h:1.22
--- src/bin/csh/csh.h:1.21	Mon Jul 16 14:26:09 2007
+++ src/bin/csh/csh.h	Wed Nov  9 14:16:00 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: csh.h,v 1.21 2007/07/16 18:26:09 christos Exp $ */
+/* $NetBSD: csh.h,v 1.22 2011/11/09 19:16:00 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -141,7 +141,7 @@ Char *shtemp;			/* Temp name for << shel
 #include <sys/time.h>
 #include <sys/types.h>
 
-struct timeval time0;		/* Time at which the shell started */
+struct timespec time0;		/* Time at which the shell started */
 struct rusage ru0;
 
 /*

Index: src/bin/csh/dol.c
diff -u src/bin/csh/dol.c:1.27 src/bin/csh/dol.c:1.28
--- src/bin/csh/dol.c:1.27	Mon Aug 29 10:51:17 2011
+++ src/bin/csh/dol.c	Wed Nov  9 14:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dol.c,v 1.27 2011/08/29 14:51:17 joerg Exp $ */
+/* $NetBSD: dol.c,v 1.28 2011/11/09 19:16:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dol.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dol.c,v 1.27 2011/08/29 14:51:17 joerg Exp $");
+__RCSID("$NetBSD: dol.c,v 1.28 2011/11/09 19:16:01 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -815,7 +815,7 @@ void
 heredoc(Char *term)
 {
     Char obuf[BUFSIZE], lbuf[BUFSIZE], mbuf[BUFSIZE];
-    struct timeval tv;
+    struct timespec tv;
     Char *Dv[2], *lbp, *obp, *mbp, **vp;
     char *tmp;
     int c, ocnt, lcnt, mcnt;
@@ -826,9 +826,9 @@ again:
     if (open(tmp, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600) < 0) {
 	if (errno == EEXIST) {
 	    if (unlink(tmp) == -1) {
-		(void)gettimeofday(&tv, NULL);
+		(void)clock_gettime(CLOCK_MONOTONIC, &tv);
 		mbp = putn((((int)tv.tv_sec) ^ 
-		    ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff);
+		    ((int)tv.tv_nsec) ^ ((int)getpid())) & 0x00ffffff);
 		shtemp = Strspl(STRtmpsh, mbp);
 		xfree((ptr_t)mbp);
 	    }

Index: src/bin/csh/extern.h
diff -u src/bin/csh/extern.h:1.23 src/bin/csh/extern.h:1.24
--- src/bin/csh/extern.h:1.23	Mon Aug 29 10:51:17 2011
+++ src/bin/csh/extern.h	Wed Nov  9 14:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.23 2011/08/29 14:51:17 joerg Exp $ */
+/* $NetBSD: extern.h,v 1.24 2011/11/09 19:16:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -288,8 +288,8 @@ void plist(struct varent *);
  */
 void donice(Char **, struct command *);
 void dotime(Char **, struct command *);
-void prusage(FILE *, struct rusage *, struct rusage *, struct timeval *,
-             struct timeval *);
+void prusage(FILE *, struct rusage *, struct rusage *, struct timespec *,
+             struct timespec *);
 void ruadd(struct rusage *, struct rusage *);
 void settimes(void);
 void psecs(long);

Index: src/bin/csh/proc.c
diff -u src/bin/csh/proc.c:1.34 src/bin/csh/proc.c:1.35
--- src/bin/csh/proc.c:1.34	Mon Jul 16 14:26:10 2007
+++ src/bin/csh/proc.c	Wed Nov  9 14:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.c,v 1.34 2007/07/16 18:26:10 christos Exp $ */
+/* $NetBSD: proc.c,v 1.35 2011/11/09 19:16:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)proc.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: proc.c,v 1.34 2007/07/16 18:26:10 christos Exp $");
+__RCSID("$NetBSD: proc.c,v 1.35 2011/11/09 19:16:01 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -109,7 +109,7 @@ found:
     }
     else {
 	if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
-	    (void)gettimeofday(&pp->p_etime, NULL);
+	    (void)clock_gettime(CLOCK_MONOTONIC, &pp->p_etime);
 
 	pp->p_rusage = ru;
 	if (WIFSIGNALED(w)) {
@@ -500,7 +500,7 @@ palloc(int pid, struct command *t)
     }
     pp->p_next = proclist.p_next;
     proclist.p_next = pp;
-    (void)gettimeofday(&pp->p_btime, NULL);
+    (void)clock_gettime(CLOCK_MONOTONIC, &pp->p_btime);
 }
 
 static void
@@ -800,9 +800,9 @@ static void
 ptprint(struct process *tp)
 {
     static struct rusage zru;
-    static struct timeval ztime;
+    static struct timespec ztime;
     struct rusage ru;
-    struct timeval tetime, diff;
+    struct timespec tetime, diff;
     struct process *pp;
 
     pp = tp;
@@ -810,8 +810,8 @@ ptprint(struct process *tp)
     tetime = ztime;
     do {
 	ruadd(&ru, &pp->p_rusage);
-	timersub(&pp->p_etime, &pp->p_btime, &diff);
-	if (timercmp(&diff, &tetime, >))
+	timespecsub(&pp->p_etime, &pp->p_btime, &diff);
+	if (timespeccmp(&diff, &tetime, >))
 	    tetime = diff;
     } while ((pp = pp->p_friends) != tp);
     prusage(cshout, &zru, &ru, &tetime, &ztime);

Index: src/bin/csh/proc.h
diff -u src/bin/csh/proc.h:1.12 src/bin/csh/proc.h:1.13
--- src/bin/csh/proc.h:1.12	Mon Jul 16 14:26:10 2007
+++ src/bin/csh/proc.h	Wed Nov  9 14:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.12 2007/07/16 18:26:10 christos Exp $ */
+/* $NetBSD: proc.h,v 1.13 2011/11/09 19:16:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -52,8 +52,8 @@ struct process {
     pid_t p_pid;
     pid_t p_jobid;		/* pid of job leader */
     /* if a job is stopped/background p_jobid gives its pgrp */
-    struct timeval p_btime;	/* begin time */
-    struct timeval p_etime;	/* end time */
+    struct timespec p_btime;	/* begin time */
+    struct timespec p_etime;	/* end time */
     struct rusage p_rusage;
     Char *p_command;		/* first PMAXLEN chars of command */
 };

Index: src/bin/csh/time.c
diff -u src/bin/csh/time.c:1.18 src/bin/csh/time.c:1.19
--- src/bin/csh/time.c:1.18	Sun Aug 28 03:49:16 2011
+++ src/bin/csh/time.c	Wed Nov  9 14:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: time.c,v 1.18 2011/08/28 07:49:16 christos Exp $ */
+/* $NetBSD: time.c,v 1.19 2011/11/09 19:16:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)time.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: time.c,v 1.18 2011/08/28 07:49:16 christos Exp $");
+__RCSID("$NetBSD: time.c,v 1.19 2011/11/09 19:16:01 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -58,7 +58,7 @@ settimes(void)
 {
     struct rusage ruch;
 
-    (void)gettimeofday(&time0, NULL);
+    (void)clock_gettime(CLOCK_MONOTONIC, &time0);
     (void)getrusage(RUSAGE_SELF, &ru0);
     (void)getrusage(RUSAGE_CHILDREN, &ruch);
     ruadd(&ru0, &ruch);
@@ -73,12 +73,12 @@ void
 dotime(Char **v, struct command *t)
 {
     struct rusage ru1, ruch;
-    struct timeval timedol;
+    struct timespec timedol;
 
     (void)getrusage(RUSAGE_SELF, &ru1);
     (void)getrusage(RUSAGE_CHILDREN, &ruch);
     ruadd(&ru1, &ruch);
-    (void)gettimeofday(&timedol, NULL);
+    (void)clock_gettime(CLOCK_MONOTONIC, &timedol);
     prusage(cshout, &ru0, &ru1, &timedol, &time0);
 }
 
@@ -127,8 +127,8 @@ ruadd(struct rusage *ru, struct rusage *
 #endif /* NOT_CSH */
 
 void
-prusage(FILE *fp, struct rusage *r0, struct rusage *r1, struct timeval *e,
-        struct timeval *b)
+prusage(FILE *fp, struct rusage *r0, struct rusage *r1, struct timespec *e,
+        struct timespec *b)
 {
 #ifndef NOT_CSH
     struct varent *vp;
@@ -139,7 +139,7 @@ prusage(FILE *fp, struct rusage *r0, str
     int ms;
 
     cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
-    ms = (e->tv_sec - b->tv_sec) * 100 + (e->tv_usec - b->tv_usec) / 10000;
+    ms = (e->tv_sec - b->tv_sec) * 100 + (e->tv_nsec - b->tv_nsec) / 10000000;
     t = (r1->ru_utime.tv_sec - r0->ru_utime.tv_sec) * 100 +
         (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 10000 +
         (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 100 +

Reply via email to