Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/csh sync with /usr/bin/time, use CLOCK_MONOTONIC
details: https://anonhg.NetBSD.org/src/rev/802a5bf9f53b
branches: trunk
changeset: 771111:802a5bf9f53b
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 09 19:16:00 2011 +0000
description:
sync with /usr/bin/time, use CLOCK_MONOTONIC
diffstat:
bin/csh/csh.h | 4 ++--
bin/csh/dol.c | 10 +++++-----
bin/csh/extern.h | 6 +++---
bin/csh/proc.c | 16 ++++++++--------
bin/csh/proc.h | 6 +++---
bin/csh/time.c | 16 ++++++++--------
6 files changed, 29 insertions(+), 29 deletions(-)
diffs (218 lines):
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/csh.h
--- a/bin/csh/csh.h Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/csh.h Wed Nov 09 19:16:00 2011 +0000
@@ -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 @@
#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;
/*
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/dol.c
--- a/bin/csh/dol.c Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/dol.c Wed Nov 09 19:16:00 2011 +0000
@@ -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 @@
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 @@
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);
}
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/extern.h
--- a/bin/csh/extern.h Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/extern.h Wed Nov 09 19:16:00 2011 +0000
@@ -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 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);
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/proc.c
--- a/bin/csh/proc.c Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/proc.c Wed Nov 09 19:16:00 2011 +0000
@@ -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 @@
}
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 @@
}
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 @@
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 @@
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);
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/proc.h
--- a/bin/csh/proc.h Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/proc.h Wed Nov 09 19:16:00 2011 +0000
@@ -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 @@
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 */
};
diff -r 3fdc2c699a8c -r 802a5bf9f53b bin/csh/time.c
--- a/bin/csh/time.c Wed Nov 09 19:10:10 2011 +0000
+++ b/bin/csh/time.c Wed Nov 09 19:16:00 2011 +0000
@@ -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 @@
{
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 @@
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 @@
#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 @@
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 +
Home |
Main Index |
Thread Index |
Old Index