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: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)times.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include <sys/time.h>
  12: #include <sys/resource.h>
  13: 
  14: /*
  15:  * Backwards compatible times.
  16:  */
  17: struct 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: 
  24: times(tmsp)
  25:     register struct tms *tmsp;
  26: {
  27:     struct rusage ru;
  28: 
  29:     if (getrusage(RUSAGE_SELF, &ru) < 0)
  30:         return (-1);
  31:     tmsp->tms_utime = scale60(&ru.ru_utime);
  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: 
  40: static
  41: scale60(tvp)
  42:     register struct timeval *tvp;
  43: {
  44: 
  45:     return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
  46: }
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: ?E00
Valid CSS Valid XHTML 1.0 Strict