summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-05-31 12:09:50 +0000
committerbde <bde@FreeBSD.org>1998-05-31 12:09:50 +0000
commit935c494c4bf852eb4f5ef6c127f307cf49a401e5 (patch)
treec95cb88a2c8f73733dc946f90bb80b39fc2e9478 /bin
parentb104067a4bf5de99affbe61bf7a5a302764433b7 (diff)
downloadFreeBSD-src-935c494c4bf852eb4f5ef6c127f307cf49a401e5.zip
FreeBSD-src-935c494c4bf852eb4f5ef6c127f307cf49a401e5.tar.gz
Fixed imperfections in previous commit (a poor variable name,
excessive 64-bit arithmetic, and excessive changes).
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/print.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index a2b69be..40ad844 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#endif
static const char rcsid[] =
- "$Id: print.c,v 1.26 1998/05/25 05:07:18 steve Exp $";
+ "$Id: print.c,v 1.27 1998/05/28 09:29:43 phk Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -446,35 +446,35 @@ cputime(k, ve)
VARENT *ve;
{
VAR *v;
- int64_t sec;
long secs;
long psecs; /* "parts" of a second. first micro, then centi */
char obuff[128];
v = ve->var;
if (KI_PROC(k)->p_stat == SZOMB || !k->ki_u.u_valid) {
- sec = 0;
+ secs = 0;
+ psecs = 0;
} else {
/*
* This counts time spent handling interrupts. We could
* fix this, but it is not 100% trivial (and interrupt
* time fractions only work on the sparc anyway). XXX
*/
- sec = KI_PROC(k)->p_runtime;
+ secs = KI_PROC(k)->p_runtime / 1000000;
+ psecs = KI_PROC(k)->p_runtime % 1000000;
if (sumrusage) {
- sec += (k->ki_u.u_cru.ru_utime.tv_sec +
- k->ki_u.u_cru.ru_stime.tv_sec) *
- (int64_t)1000000;
- sec += k->ki_u.u_cru.ru_utime.tv_usec +
+ secs += k->ki_u.u_cru.ru_utime.tv_sec +
+ k->ki_u.u_cru.ru_stime.tv_sec;
+ psecs += k->ki_u.u_cru.ru_utime.tv_usec +
k->ki_u.u_cru.ru_stime.tv_usec;
}
+ /*
+ * round and scale to 100's
+ */
+ psecs = (psecs + 5000) / 10000;
+ secs += psecs / 100;
+ psecs = psecs % 100;
}
- /*
- * round and scale to 100's
- */
- sec = (sec + 5000) / 10000;
- secs = sec / 100;
- psecs = sec % 100;
(void)snprintf(obuff, sizeof(obuff),
"%3ld:%02ld.%02ld", secs/60, secs%60, psecs);
(void)printf("%*s", v->width, obuff);
OpenPOWER on IntegriCloud