[ntpsec commit] Build the util/precision.c utility.
Eric S. Raymond
esr at ntpsec.org
Wed Sep 30 15:40:47 UTC 2015
Module: ntpsec
Branch: master
Commit: 65042c2bd12d7e7adcff1324edcd4a19ab37238a
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=65042c2bd12d7e7adcff1324edcd4a19ab37238a
Author: Eric S. Raymond <esr at thyrsus.com>
Date: Wed Sep 30 10:35:58 2015 -0400
Build the util/precision.c utility.
Revert the half-baked attempt to make it use clock_gettime(). To be fixed
later.
---
util/precision.c | 14 ++++++++++++--
util/wscript | 11 +++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/util/precision.c b/util/precision.c
index 1a92576..5152ac2 100644
--- a/util/precision.c
+++ b/util/precision.c
@@ -119,7 +119,9 @@ default_get_precision(void)
{
struct timeval tp;
struct timezone tzp;
+#ifdef HAVE_GETCLOCK
struct timespec ts;
+#endif
long last;
int i;
long diff;
@@ -128,14 +130,22 @@ default_get_precision(void)
usec = 0;
val = MAXSTEP;
- (void) clock_gettime(CLOCK_GETTIME, &ts);
+#ifdef HAVE_GETCLOCK
+ (void) getclock(TIMEOFDAY, &ts);
tp.tv_sec = ts.tv_sec;
tp.tv_usec = ts.tv_nsec / 1000;
+#else /* not HAVE_GETCLOCK */
+ gettimeofday(&tp, &tzp);
+#endif /* not HAVE_GETCLOCK */
last = tp.tv_usec;
for (i = 0; i < MINLOOPS && usec < HUSECS;) {
- (void) clock_gettime(CLOCK_REALTIME, &ts);
+#ifdef HAVE_GETCLOCK
+ (void) getclock(TIMEOFDAY, &ts);
tp.tv_sec = ts.tv_sec;
tp.tv_usec = ts.tv_nsec / 1000;
+#else /* not HAVE_GETCLOCK */
+ gettimeofday(&tp, &tzp);
+#endif /* not HAVE_GETCLOCK */
diff = tp.tv_usec - last;
last = tp.tv_usec;
if (diff < 0)
diff --git a/util/wscript b/util/wscript
index 8d0c509..b4abd02 100644
--- a/util/wscript
+++ b/util/wscript
@@ -26,3 +26,14 @@ def build(ctx):
install_path= "${PREFIX}/sbin/"
)
+ ctx(
+ target = "precision",
+ features = "c cprogram bld_include src_include libisc_include",
+ source = ["precision.c"],
+ includes = [
+ "%s/precision/" % bldnode
+ ],
+ use = "ntp opts isc M RT PTHREAD",
+ install_path= "${PREFIX}/sbin/"
+ )
+
More information about the vc
mailing list