home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / gen_library / rcs / clock.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  2.1 KB  |  90 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.2
  10. date    92.07.04.20.07.44;    author mwild;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    92.06.08.18.31.20;    author mwild;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @initial checkin
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @use <machine/limits.h> instead of outdated <machine/machlimits.h>
  28. @
  29. text
  30. @/*
  31.  * Copyright (c) 1989 The Regents of the University of California.
  32.  * All rights reserved.
  33.  *
  34.  * Redistribution and use in source and binary forms are permitted
  35.  * provided that: (1) source distributions retain this entire copyright
  36.  * notice and comment, and (2) distributions including binaries display
  37.  * the following acknowledgement:  ``This product includes software
  38.  * developed by the University of California, Berkeley and its contributors''
  39.  * in the documentation or other materials provided with the distribution
  40.  * and in all advertising materials mentioning features or use of this
  41.  * software. Neither the name of the University nor the names of its
  42.  * contributors may be used to endorse or promote products derived
  43.  * from this software without specific prior written permission.
  44.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  45.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  46.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  47.  */
  48.  
  49. #if defined(LIBC_SCCS) && !defined(lint)
  50. static char sccsid[] = "@@(#)clock.c    5.3 (Berkeley) 6/1/90";
  51. #endif /* LIBC_SCCS and not lint */
  52.  
  53. #define KERNEL
  54. #include "ixemul.h"
  55.  
  56. #include <machine/limits.h>
  57. #include <sys/time.h>
  58. #include <sys/resource.h>
  59.  
  60. time_t
  61. clock()
  62. {
  63.   struct rusage rusage;
  64.   time_t val;
  65.  
  66.   if (syscall (SYS_getrusage, RUSAGE_SELF, &rusage))
  67.     return ((time_t) -1);
  68.  
  69.   val = (rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec) * CLK_TCK;
  70.   /*
  71.    * Convert usec to clock ticks; could do (usec * CLK_TCK) / 1000000,
  72.    * but this would overflow if we switch to nanosec.
  73.    */
  74.   val += (rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec) /
  75.       (1000000 / CLK_TCK);
  76.   return (val);
  77. }
  78. @
  79.  
  80.  
  81. 1.1
  82. log
  83. @Initial revision
  84. @
  85. text
  86. @d27 1
  87. a27 1
  88. #include <machine/machlimits.h>
  89. @
  90.