* Copyright (c) 1990 The Regents of the University of California.
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)times.c 5.4 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/resource.h>
* Convert usec to clock ticks; could do (usec * CLK_TCK) / 1000000,
* but this would overflow if we switch to nanosec.
#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
if (getrusage(RUSAGE_SELF
, &ru
) < 0)
tp
->tms_utime
= CONVTCK(ru
.ru_utime
);
tp
->tms_stime
= CONVTCK(ru
.ru_stime
);
if (getrusage(RUSAGE_CHILDREN
, &ru
) < 0)
tp
->tms_cutime
= CONVTCK(ru
.ru_utime
);
tp
->tms_cstime
= CONVTCK(ru
.ru_stime
);
if (gettimeofday(&t
, (struct timezone
*)0))
return ((clock_t)(CONVTCK(t
)));