-
Notifications
You must be signed in to change notification settings - Fork 11
/
adjtimex.c
39 lines (30 loc) · 1.12 KB
/
adjtimex.c
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
// 2020, Georg Sauthoff <[email protected]>
//
// Display some clock related system settings.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <stdio.h>
#include <sys/timex.h>
int main()
{
struct timex t = {0};
int r = adjtimex(&t);
if (r == -1) {
perror("adjtimex");
return 1;
}
// this flag is removed by NTP/daemons such as chrony/ptp4l
// exception: the Solarflare PTPd doesn't remove this flag
// with STA_UNSYNC unset the kernel writes to the RTC every 11 minutes
printf("Clock is %ssynchronized (%s)\n", t.status & STA_UNSYNC ? "un" : "",
t.status & STA_UNSYNC ? "STA_UNSYNC" : "STA_UNSYNC unset");
printf("Maxerror: %ld us\n", t.maxerror);
// the offset the kernel uses for CLOCK_TAI,
// i.e. clock_gettime(CLOCK_TAI) == clock_gettime(CLOCK_REALTIME) + tai_off
printf("TAI offset: %d s\n", t.tai);
printf("PPS frequency discipline (STA_PPSFREQ): %s\n",
t.status & STA_PPSFREQ ? "enabled" : "disabled");
printf("PPS time discipline (STA_PPSTIME): %s\n",
t.status & STA_PPSTIME ? "enabled" : "disabled");
return 0;
}