Debian Codegraph @

utils/pmx/pmx-src/libf2c/dtime_.c

raw
1 #include "time.h"
2
3 #ifdef MSDOS
4 #undef USE_CLOCK
5 #define USE_CLOCK
6 #endif
7
8 #ifndef REAL
9 #define REAL double
10 #endif
11
12 #ifndef USE_CLOCK
13 #define _INCLUDE_POSIX_SOURCE /* for HP-UX */
14 #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */
15 #include "sys/types.h"
16 #include "sys/times.h"
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 #endif
21
22 #undef Hz
23 #ifdef CLK_TCK
24 #define Hz CLK_TCK
25 #else
26 #ifdef HZ
27 #define Hz HZ
28 #else
29 #define Hz 60
30 #endif
31 #endif
32
33 REAL
34 #ifdef KR_headers
35 dtime_(tarray) float *tarray;
36 #else
37 dtime_(float *tarray)
38 #endif
39 {
40 #ifdef USE_CLOCK
41 #ifndef CLOCKS_PER_SECOND
42 #define CLOCKS_PER_SECOND Hz
43 #endif
44 static double t0;
45 double t = clock();
46 tarray[1] = 0;
47 tarray[0] = (t - t0) / CLOCKS_PER_SECOND;
48 t0 = t;
49 return tarray[0];
50 #else
51 struct tms t;
52 static struct tms t0;
53
54 times(&t);
55 tarray[0] = (double)(t.tms_utime - t0.tms_utime) / Hz;
56 tarray[1] = (double)(t.tms_stime - t0.tms_stime) / Hz;
57 t0 = t;
58 return tarray[0] + tarray[1];
59 #endif
60 }
61 #ifdef __cplusplus
62 }
63 #endif