]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Let there be fuzz. Make sure sys_precision is visible and present.
authorHarlan Stenn <stenn@ntp.org>
Fri, 24 Feb 2006 09:20:07 +0000 (04:20 -0500)
committerHarlan Stenn <stenn@ntp.org>
Fri, 24 Feb 2006 09:20:07 +0000 (04:20 -0500)
bk: 43fecfc7PWWbTr7Sg4km_-aIMSta3g

libntp/systime.c
ntpdate/ntpdate.c
ntpdc/ntpdc.c
ntpq/ntpq.c

index 4c7234a6e4c8b18930bdf2b0631cb156f9da6540..4539b5fec3ce4bf92d31dd6cac6fce90c92952e9 100644 (file)
 #include "ntp_unixtime.h"
 #include "ntp_stdlib.h"
 #include "ntp_random.h"
+#include "ntpd.h"              /* for sys_precision */
 
 #ifdef SIM
-#include "ntpsim.h"
+# include "ntpsim.h"
 #endif /*SIM */
 
 #ifdef HAVE_SYS_PARAM_H
@@ -63,6 +64,7 @@ get_systime(
        /*
         * Convert Unix clock from seconds and nanoseconds to seconds.
         * The bottom is only two bits down, so no need for fuzz.
+        * Some systems don't have that level of precision, however...
         */
 # ifdef HAVE_CLOCK_GETTIME
        clock_gettime(CLOCK_REALTIME, &ts);
@@ -83,8 +85,10 @@ get_systime(
        now->l_i = tv.tv_sec + JAN_1970;
        dtemp = tv.tv_usec / 1e6;
 
+#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+
        /*
-        * ntp_random() produces 31 bits (always nonnegative.
+        * ntp_random() produces 31 bits (always nonnegative).
         * This bit is done only after the precision has been
         * determined.
         */
@@ -92,8 +96,6 @@ get_systime(
                dtemp += (ntp_random() / FRAC - .5) / (1 <<
                    -sys_precision);
 
-#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
-
        /*
         * Renormalize to seconds past 1900 and fraction.
         */
@@ -192,11 +194,11 @@ step_systime(
                    (double)adjtv.tv_sec) * 1e6 + .5);
        }
 #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
-#ifdef HAVE_CLOCK_GETTIME
+# ifdef HAVE_CLOCK_GETTIME
        (void) clock_gettime(CLOCK_REALTIME, &ts);
-#else
+# else
        (void) getclock(TIMEOFDAY, &ts);
-#endif
+# endif
        timetv.tv_sec = ts.tv_sec;
        timetv.tv_usec = ts.tv_nsec / 1000;
 #else /*  not HAVE_GETCLOCK */
index 96546644ab59bf6316956f105c6943026b2ce644..e1fe65eb9ce2b1f8a1c1222819170a020a84672c 100644 (file)
@@ -115,6 +115,11 @@ static timer_t ntpdate_timerid;
 #define NTP_MAXLIST 5  /* maximum select list size */
 #define PEER_SHIFT     8       /* 8 suitable for crystal time base */
 
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
 /*
  * Debugging flag
  */
index 4c73b001b31e2031d72ebaa2025aa62c26e4a4f0..98a5d7daffcdeae7996ebf97e82848967d363727 100644 (file)
@@ -56,6 +56,11 @@ static       u_long  info_auth_keyid;
 static int info_auth_keytype = KEY_TYPE_MD5;   /* MD5 */
 u_long current_time;           /* needed by authkeys; not used */
 
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
 int            ntpdcmain       P((int, char **));
 /*
  * Built in command handler declarations
index 6994e36a87ea1962cab914304933830732a8b99d..05b5bf50e9f68b2bb934f86e555d8ba264752097 100644 (file)
@@ -47,6 +47,11 @@ int interactive = 0;         /* set to 1 when we should prompt */
 const char *prompt = "ntpq> "; /* prompt to ask him about */
 
 
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
 /*
  * Keyid used for authenticated requests.  Obtained on the fly.
  */