minor printf format error
[unix-history] / usr / src / lib / libc / gen / times.c
CommitLineData
bb0cfa24
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
2ce81398
DS
7#if defined(LIBC_SCCS) && !defined(lint)
8static char sccsid[] = "@(#)times.c 5.2 (Berkeley) %G%";
9#endif LIBC_SCCS and not lint
9af2a874
SL
10
11#include <sys/time.h>
12#include <sys/resource.h>
13
14/*
15 * Backwards compatible times.
16 */
17struct tms {
18 int tms_utime; /* user time */
19 int tms_stime; /* system time */
20 int tms_cutime; /* user time, children */
21 int tms_cstime; /* system time, children */
22};
23
24times(tmsp)
59cb1e5a 25 register struct tms *tmsp;
9af2a874
SL
26{
27 struct rusage ru;
28
29 if (getrusage(RUSAGE_SELF, &ru) < 0)
30 return (-1);
59cb1e5a 31 tmsp->tms_utime = scale60(&ru.ru_utime);
9af2a874
SL
32 tmsp->tms_stime = scale60(&ru.ru_stime);
33 if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
34 return (-1);
35 tmsp->tms_cutime = scale60(&ru.ru_utime);
36 tmsp->tms_cstime = scale60(&ru.ru_stime);
37 return (0);
38}
39
40static
41scale60(tvp)
42 register struct timeval *tvp;
43{
44
45 return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
46}