[ntpsec commit] Port tickadj so it can use ntp_adjtime, if present, and...
Eric S. Raymond
esr at ntpsec.org
Thu Oct 8 17:08:41 UTC 2015
Module: ntpsec
Branch: master
Commit: de6caf38f38b77207c5ee018e5dbe1af309243a7
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=de6caf38f38b77207c5ee018e5dbe1af309243a7
Author: Eric S. Raymond <esr at thyrsus.com>
Date: Thu Oct 8 13:07:36 2015 -0400
Port tickadj so it can use ntp_adjtime, if present, and...
...use this to simplify the util build recipe.
---
docs/tickadj.txt | 5 +++--
util/tickadj.c | 17 +++++++++++++----
util/wscript | 25 +------------------------
3 files changed, 17 insertions(+), 30 deletions(-)
diff --git a/docs/tickadj.txt b/docs/tickadj.txt
index 561227f..9779f50 100644
--- a/docs/tickadj.txt
+++ b/docs/tickadj.txt
@@ -7,7 +7,8 @@
== Description ==
The `tickadj` program reads, and optionally modifies, several
-timekeeping-related variables. It uses the adjtimex(2) system call.
+timekeeping-related variables. It relies on the adjtimex(2) or
+ntp_adjtime(2) system calls.
These tweaks are almost never necessary on hardware new enough to have
a fully POSIX.1-2001-conformant Unix. This utility is deprecated and
@@ -23,7 +24,7 @@ be members of the `struct timex` that adjtimex(2) operates on.
By default, with no arguments, `tickadj` reads the `struct timex`
variable(s) of interest and displays them. At the same time, it
determines an "optimal" value for the value of the `tickadj` variable
-if the intent is to run the `{ntpd}` Network Time Protocol (NTP) daemon,
+if the intent is to run the Network Time Protocol (NTP) daemon,
and prints this as well. Since the operation of `tickadj` when reading
the kernel mimics the operation of similar parts of the `{ntpd}` program
fairly closely, this can be useful when debugging problems with
diff --git a/util/tickadj.c b/util/tickadj.c
index 8547eb4..95327d8 100644
--- a/util/tickadj.c
+++ b/util/tickadj.c
@@ -1,9 +1,9 @@
/*
* tickadj - read, and possibly modify, the kernel `tick' and
- * `tickadj' variables', using adjtimex(2). This is
- * included only for compatibility with old scripts.
- * and its former support for unsafe /dev/kmem operations
- * has been removed.
+ * `tickadj' variables', using adjtimex(2) or
+ * ntp_adjtime(2). This is included only for compatibility
+ * with old scripts. and its former support for unsafe
+ * /dev/kmem operations has been removed.
*/
#include <config.h>
@@ -66,10 +66,19 @@ int main(
#endif
}
+#ifdef HAVE_ADJTIMEX
if (adjtimex(&txc) < 0)
{
perror("adjtimex");
}
+#elif HAVE_NTP_ADJTIME
+ if (ntp_adjtime(&txc) < 0)
+ {
+ perror("ntp_adjtime");
+ }
+#else
+#error Either adjtimex or ntp_adjtime(2) is required.
+#endif
else
{
#ifdef STRUCT_TIMEX_HAS_TIME_TICK
diff --git a/util/wscript b/util/wscript
index b682b92..25dfdf5 100644
--- a/util/wscript
+++ b/util/wscript
@@ -4,30 +4,7 @@ def build(ctx):
srcnode = ctx.srcnode.abspath()
bldnode = ctx.bldnode.abspath()
- if ctx.get_define("HAVE_TICKADJ"):
- ctx(
- target = "tickadj",
- features = "c cprogram bld_include src_include",
- source = ["tickadj.c"],
- includes = [
- "%s/tickadj/" % bldnode
- ],
- use = "ntp opts isc M RT",
- install_path= "${PREFIX}/sbin/"
- )
-
- ctx(
- target = "ntptime",
- features = "c cprogram bld_include src_include libisc_include",
- source = ["ntptime.c"],
- includes = [
- "%s/ntptime/" % bldnode
- ],
- use = "ntp opts isc M RT PTHREAD",
- install_path= "${PREFIX}/sbin/"
- )
-
- util = ['hist', 'jitter', 'precision', 'propdelay', 'sht', 'testrs6000', 'tg2']
+ util = ['hist', 'jitter', 'precision', 'propdelay', 'ntptime', 'sht', 'testrs6000', 'tg2', 'tickadj']
if ctx.get_define("HAVE_SYS_TIMEPPS_H"):
util += ["pps-api"]
More information about the vc
mailing list