blob: 3d14f96e3355581ee849a625c9864399c1cb1093 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* ISC license. */
#include <skalibs/config.h>
#include <skalibs/sysdeps.h>
#include <skalibs/tai.h>
#ifdef SKALIBS_FLAG_USERT
# ifndef SKALIBS_HASCLOCKRT
# undef SKALIBS_FLAG_USERT
# warning "SKALIBS_FLAG_USERT set but SKALIBS_HASCLOCKRT not found. Clearing SKALIBS_FLAG_USERT."
# endif
#endif
#ifdef SKALIBS_FLAG_USERT
#include <time.h>
int sysclock_get (tain_t *a)
{
tain_t aa ;
struct timespec now ;
if (clock_gettime(CLOCK_REALTIME, &now) < 0) return 0 ;
if (!tain_from_timespec(&aa, &now)) return 0 ;
tain_add(a, &aa, &tain_nano500) ;
return 1 ;
}
#else
#include <sys/time.h>
int sysclock_get (tain_t *a)
{
tain_t aa ;
struct timeval now ;
if (gettimeofday(&now, 0) < 0) return 0 ;
if (!tain_from_timeval(&aa, &now)) return 0 ;
tain_add(a, &aa, &tain_nano500) ;
return 1 ;
}
#endif
|