CLOCK_TAI 基本上设计为 CLOCK_REALTIME(UTC) + tai_offset。
我使用代码来测试 TAI 和 REALTIME 之间的区别。
但是我在Raspberry pi和OpenWRT上得到了不同的结果。
#include <stdio.h>
#include <time.h>
#ifndef CLOCK_TAI
#define CLOCK_TAI 11
#endif
int main()
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
printf("CLOCK_REALTIME: %d, %ld\n", ts.tv_sec, ts.tv_nsec);
clock_gettime(CLOCK_TAI, &ts);
printf("CLOCK_TAI: %d, %ld\n", ts.tv_sec, ts.tv_nsec);
return 0;
}
我还从以下网址下载了leapfile:https ://www.ietf.org/timezones/data/leap-seconds.list
并添加leapfile "/path/to your/leap-file"
/etc/ntp.conf
在这个时候,diff seconds 应该是 37 秒(检查leap-seconds.list)
这是我在 Raspberry pi 中的预期结果:
CLOCK_REALTIME : 1497357750, 808013378
CLOCK_TAI : 1497357787, 809035924
(1497357787-1497357750 = 37)
但是当我在 OpenWRT 中做同样的事情时。REALTIME 和 TAI 几乎相同。
CLOCK_REALTIME : 1497355658, 843078207
CLOCK_TAI : 1497355658, 843287721
# ntpq -crv
associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
version="ntpd 4.2.8p10@1.3728-o Tue Jun 13 11:54:10 UTC 2017 (1)",
processor="mips", system="Linux/3.10.14", leap=00, stratum=2,
precision=-17, rootdelay=5.275, rootdisp=192.843, refid=59.125.122.217,
reftime=dcea5404.21137eb8 Tue, Jun 13 2017 12:07:32.129,
clock=dcea542d.f1399189 Tue, Jun 13 2017 12:08:13.942, peer=28311, tc=6,
mintc=3, offset=-2.809440, frequency=0.000, sys_jitter=1.576573,
clk_jitter=0.936, clk_wander=0.000, tai=37, leapsec=201701010000,
expire=201712280000
openWRT 信息:
- openwrt:barrier_breaker 14.07
- uClibc 0.9.33.2
- 带有 Linaro 增强功能的 gcc 4.8.x
- ntpd - NTP 守护程序 - 版本。4.2.8p10
- Linux 内核:3.10.14 mips
有人可以给我一些建议吗?