blob: 1325903f5a8354e8f405b4cf4ec344a54348b811 (
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
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#include <skalibs/tai.h>
#ifdef SKALIBS_HASCLOCKRT
#include <time.h>
int sysclock_get (tain *a)
{
tain 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 *a)
{
tain 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
|