Initial revision
[official-gcc.git] / gcc / f / runtime / libF77 / dtime_.c
blob2e775c6b84eb2f213e6f242f5379ea86e7a6e078
1 #include "time.h"
2 #ifndef USE_CLOCK
3 #include "sys/types.h"
4 #include "sys/times.h"
5 #endif
7 #undef Hz
8 #ifdef CLK_TCK
9 #define Hz CLK_TCK
10 #else
11 #ifdef HZ
12 #define Hz HZ
13 #else
14 #define Hz 60
15 #endif
16 #endif
18 float
19 #ifdef KR_headers
20 dtime_(tarray) float *tarray;
21 #else
22 dtime_(float *tarray)
23 #endif
25 #ifdef USE_CLOCK
26 #ifndef CLOCKS_PER_SECOND
27 #define CLOCKS_PER_SECOND Hz
28 #endif
29 static double t0;
30 double t = clock();
31 tarray[1] = 0;
32 tarray[0] = (t - t0) / CLOCKS_PER_SECOND;
33 t0 = t;
34 return tarray[0];
35 #else
36 struct tms t;
37 static struct tms t0;
39 times(&t);
40 tarray[0] = (t.tms_utime - t0.tms_utime) / Hz;
41 tarray[1] = (t.tms_stime - t0.tms_stime) / Hz;
42 t0 = t;
43 return tarray[0] + tarray[1];
44 #endif