1 |
jmc |
1.4 |
/* |
2 |
|
|
* $Header: $ |
3 |
|
|
* $Name: $ |
4 |
|
|
*/ |
5 |
heimbach |
1.1 |
#include <sys/types.h> |
6 |
|
|
#include <sys/times.h> |
7 |
|
|
#include <sys/time.h> |
8 |
ce107 |
1.2 |
#include <unistd.h> |
9 |
|
|
/* Here, we get the definition of the FC_NAMEMANGLE() macro. */ |
10 |
|
|
#include "FC_NAMEMANGLE.h" |
11 |
|
|
|
12 |
|
|
static long clktck = 0; |
13 |
|
|
static double invclktck = 0.0; |
14 |
|
|
|
15 |
cnh |
1.3 |
double FC_NAMEMANGLE(cusertime) (void); |
16 |
|
|
double FC_NAMEMANGLE(csystemtime) (void); |
17 |
ce107 |
1.2 |
double FC_NAMEMANGLE(timenow) (); |
18 |
|
|
void init_timer(); |
19 |
heimbach |
1.1 |
|
20 |
ce107 |
1.2 |
void init_timer() |
21 |
|
|
{ |
22 |
|
|
clktck = sysconf(_SC_CLK_TCK); |
23 |
|
|
invclktck = 1.0/clktck; |
24 |
|
|
return; |
25 |
|
|
} |
26 |
heimbach |
1.1 |
|
27 |
cnh |
1.3 |
double FC_NAMEMANGLE(cusertime) (void) |
28 |
heimbach |
1.1 |
{ |
29 |
|
|
clock_t blabla; |
30 |
|
|
struct tms timest; |
31 |
ce107 |
1.2 |
/* This is useless overhead but we'd need to call init_timer() elsewhere */ |
32 |
|
|
if (clktck == 0) init_timer(); |
33 |
|
|
|
34 |
heimbach |
1.1 |
blabla = times(×t); |
35 |
ce107 |
1.2 |
return invclktck*timest.tms_utime; |
36 |
heimbach |
1.1 |
|
37 |
|
|
} |
38 |
|
|
|
39 |
cnh |
1.3 |
double FC_NAMEMANGLE(csystemtime) (void) |
40 |
heimbach |
1.1 |
{ |
41 |
|
|
clock_t blabla; |
42 |
|
|
struct tms timest; |
43 |
ce107 |
1.2 |
/* This is useless overhead but we'd need to call init_timer() elsewhere */ |
44 |
|
|
if (clktck == 0) init_timer(); |
45 |
heimbach |
1.1 |
|
46 |
|
|
blabla = times(×t); |
47 |
ce107 |
1.2 |
return invclktck*timest.tms_stime; |
48 |
heimbach |
1.1 |
|
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
ce107 |
1.2 |
double FC_NAMEMANGLE(timenow) (void) |
54 |
heimbach |
1.1 |
{ |
55 |
|
|
struct timeval timestr; |
56 |
|
|
void *Tzp=0; |
57 |
|
|
gettimeofday(×tr, Tzp); |
58 |
|
|
|
59 |
|
|
return (double)timestr.tv_sec+1.0E-06*(double)timestr.tv_usec; |
60 |
|
|
} |
61 |
|
|
|