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