/[gnats]/gnats/libiberty/getruntime.c
ViewVC logotype

Diff of /gnats/libiberty/getruntime.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by jsm, Tue Oct 26 07:10:16 1999 UTC revision 1.3 by pdm, Mon Dec 10 23:03:26 2001 UTC
# Line 26  Boston, MA 02111-1307, USA.  */ Line 26  Boston, MA 02111-1307, USA.  */
26     single way is available for all host systems, nor are there reliable     single way is available for all host systems, nor are there reliable
27     ways to find out which way is correct for a given host. */     ways to find out which way is correct for a given host. */
28    
29  #include <time.h>  #ifdef TIME_WITH_SYS_TIME
30    # include <sys/time.h>
31    # include <time.h>
32    #else
33    # if HAVE_SYS_TIME_H
34    #  include <sys/time.h>
35    # else
36    #  ifdef HAVE_TIME_H
37    #   include <time.h>
38    #  endif
39    # endif
40    #endif
41    
42  #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)  #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
 #include <sys/time.h>  
43  #include <sys/resource.h>  #include <sys/resource.h>
44  #endif  #endif
45    
# Line 40  Boston, MA 02111-1307, USA.  */ Line 50  Boston, MA 02111-1307, USA.  */
50  #include <sys/times.h>  #include <sys/times.h>
51  #endif  #endif
52    
53    #ifdef HAVE_UNISTD_H
54    #include <unistd.h>
55    #endif
56    
57  /* This is a fallback; if wrong, it will likely make obviously wrong  /* This is a fallback; if wrong, it will likely make obviously wrong
58     results. */     results. */
59    
# Line 47  Boston, MA 02111-1307, USA.  */ Line 61  Boston, MA 02111-1307, USA.  */
61  #define CLOCKS_PER_SEC 1  #define CLOCKS_PER_SEC 1
62  #endif  #endif
63    
64  #if defined (HAVE_TIMES) && ! defined (HZ)  #ifdef _SC_CLK_TCK
65  #define HZ CLOCKS_PER_SEC  #define GNU_HZ  sysconf(_SC_CLK_TCK)
66    #else
67    #ifdef HZ
68    #define GNU_HZ  HZ
69    #else
70    #ifdef CLOCKS_PER_SEC
71    #define GNU_HZ  CLOCKS_PER_SEC
72    #endif
73    #endif
74  #endif  #endif
75    
76  long  long
# Line 65  get_run_time () Line 87  get_run_time ()
87    struct tms tms;    struct tms tms;
88    
89    times (&tms);    times (&tms);
90    return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);    return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
91  #else /* ! HAVE_TIMES */  #else /* ! HAVE_TIMES */
92    /* Fall back on clock and hope it's correctly implemented. */    /* Fall back on clock and hope it's correctly implemented. */
93    const long clocks_per_sec = CLOCKS_PER_SEC;    const long clocks_per_sec = CLOCKS_PER_SEC;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26