summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 37fe166)
raw | patch | inline | side by side (parent: 37fe166)
author | Matwey V. Kornilov <matwey.kornilov@gmail.com> | |
Wed, 6 Jul 2016 13:00:55 +0000 (16:00 +0300) | ||
committer | Matwey V. Kornilov <matwey.kornilov@gmail.com> | |
Sat, 16 Jul 2016 06:42:19 +0000 (09:42 +0300) |
When STA_NANO is set in ik->status, then results are
expressed in nanoseconds (instead of microseconds by default).
Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
expressed in nanoseconds (instead of microseconds by default).
Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
src/ntpd.c | patch | blob | history |
diff --git a/src/ntpd.c b/src/ntpd.c
index 1071d0b34544aa773017f483381f69333f239234..34a084b2be5690f46ff1c549a3338ffe32473cad 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
# include <poll.h>
#endif
+#ifndef STA_NANO
+# define STA_NANO 0x2000
+#endif
+
static const char *config_keys[] =
{
"Host",
int i;
/* On Linux, if the STA_NANO bit is set in ik->status, then ik->offset
- * is is nanoseconds, otherwise it's microseconds.
- * TODO(octo): STA_NANO is defined in the Linux specific <sys/timex.h> header. */
+ * is is nanoseconds, otherwise it's microseconds. */
double scale_loop = 1e-6;
double scale_error = 1e-6;
return (-1);
}
+ if (ntohs(ik->status) & STA_NANO) {
+ scale_loop = 1e-9;
+ scale_error = 1e-9;
+ }
+
/* kerninfo -> estimated error */
offset_loop = scale_loop * ((gauge_t) ntohl (ik->offset));
freq_loop = ntpd_read_fp (ik->freq);