OSDN Git Service

* decl.c (xref_basetypes): Refactor.
[pf3gnuchains/gcc-fork.git] / libf2c / libF77 / dtime_.c
1 #include "time.h"
2
3 #ifdef MSDOS
4 #undef USE_CLOCK
5 #define USE_CLOCK
6 #endif
7
8 #ifndef USE_CLOCK
9 #define _INCLUDE_POSIX_SOURCE   /* for HP-UX */
10 #define _INCLUDE_XOPEN_SOURCE   /* for HP-UX */
11 #include "sys/types.h"
12 #include "sys/times.h"
13 #endif
14
15 #undef Hz
16 #ifdef CLK_TCK
17 #define Hz CLK_TCK
18 #else
19 #ifdef HZ
20 #define Hz HZ
21 #else
22 #define Hz 60
23 #endif
24 #endif
25
26 double
27 dtime_ (float *tarray)
28 {
29 #ifdef USE_CLOCK
30 #ifndef CLOCKS_PER_SECOND
31 #define CLOCKS_PER_SECOND Hz
32 #endif
33   static double t0;
34   double t = clock ();
35   tarray[1] = 0;
36   tarray[0] = (t - t0) / CLOCKS_PER_SECOND;
37   t0 = t;
38   return tarray[0];
39 #else
40   struct tms t;
41   static struct tms t0;
42
43   times (&t);
44   tarray[0] = (double) (t.tms_utime - t0.tms_utime) / Hz;
45   tarray[1] = (double) (t.tms_stime - t0.tms_stime) / Hz;
46   t0 = t;
47   return tarray[0] + tarray[1];
48 #endif
49 }