File Coverage

ulib/gettime.c
Criterion Covered Total %
statement 7 13 53.8
branch 2 4 50.0
condition n/a
subroutine n/a
pod n/a
total 9 17 52.9


line stmt bran cond sub pod time code
1             #ifdef __cplusplus
2             extern "C" {
3             #endif
4              
5             #include "ulib/gettime.h"
6              
7             #ifdef __cplusplus
8             }
9             #endif
10              
11              
12             void (*uu_gettime_U2time)(pTHX_ UV ret[2]);
13              
14             /* called at boot */
15 215           void uu_gettime_init(pUCXT) {
16             SV **svp;
17 215           require_pv("Time/HiRes.pm");
18 215           svp = hv_fetchs(PL_modglobal, "Time::U2time", 0);
19 215 50         if (!svp) croak("Time::HiRes is required");
20 215 50         if (!SvIOK(*svp)) croak("Time::U2time isn't a function pointer");
21 215           uu_gettime_U2time = INT2PTR(void(*)(pTHX_ UV ret[2]), SvIV(*svp));
22             /*
23             if (0) {
24             UV xx[2];
25             (*uu_gettime_U2time)(aTHX_ xx);
26             printf("The current seconds are: %" UVuf ".%06" UVuf "\n", xx[0], xx[1]);
27             exit(0);
28             }
29             */
30 215           }
31              
32 0           U64 uu_gettime_100ns64(pUCXT) {
33             struct timeval tv;
34             U64 rv;
35             UV ptod[2];
36              
37             /* gettimeofday(&tv, 0); */
38 0           (*uu_gettime_U2time)(aTHX_ ptod);
39 0           tv.tv_sec = (long)ptod[0];
40 0           tv.tv_usec = (long)ptod[1];
41              
42 0           rv = tv.tv_sec * 10000000 + tv.tv_usec * 10;
43 0           return rv;
44             }
45              
46             /* ex:set ts=2 sw=2 itab=spaces: */