]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, ntptime.c:
authorHarlan Stenn <stenn@ntp.org>
Wed, 21 Jul 1999 01:20:53 +0000 (01:20 -0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 21 Jul 1999 01:20:53 +0000 (01:20 -0000)
  * util/ntptime.c: FreeBSD nano patches
  From: Per Hedeland <per@erix.ericsson.se>
  (similar patch from Allen Smith <easmith@beatrice.rutgers.edu>)

bk: 37952075xma9OtGv8_CiMqYXlYvrcQ

ChangeLog
util/ntptime.c

index dc6c8767b0ede07d966881e5425a076b9f6c7a05..2bd56e8bf7f7e7138aec412f173d401688e33072 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 1999-07-20  Harlan Stenn  <stenn@whimsy.udel.edu>
 
+       * util/ntptime.c: FreeBSD nano patches
+       From: Per Hedeland <per@erix.ericsson.se>
+       (similar patch from Allen Smith <easmith@beatrice.rutgers.edu>)
+
        * include/ntp.h:
        include/ntp_fp.h:
        include/ntp_io.h:
index aa964955d293671ac1bd700d93f3f40bd1c8bece..2dc9297f1b607fab895182d959ac16e14e1fe32c 100644 (file)
 # endif /* SYS_DECOSF1 */
 #endif
 
+/* FIXME? On FreeBSD 3.2(+), the 'time' element of a struct ntptimeval
+   is a struct timespec (s/ns), not a struct timeval (s/us) - which
+   seems intimately related to the fact that <sys/timex.h> also #defines
+   STA_NANO - which doesn't mean that this is the right thing to do... */
+#ifdef STA_NANO
+#define tv_frac_sec tv_nsec
+#else
+#define tv_frac_sec tv_usec
+#endif
+
+
 #define TIMEX_MOD_BITS \
 "\20\1OFFSET\2FREQUENCY\3MAXERROR\4ESTERROR\5STATUS\6TIMECONST\
 \13PLL\14FLL\15MICRO\16NANO\17CLKB\20CLKA"
@@ -76,10 +87,11 @@ main(
 #else
        struct ntptimeval ntv;
 #endif
+       struct timeval tv;
        struct timex ntx, _ntx;
        int     times[20];
        double ftemp, gtemp, htemp;
-       long time_frac;                         /* ntv.time.tv_usec (us/ns) */
+       long time_frac;                         /* ntv.time.tv_frac_sec (us/ns) */
        l_fp ts;
        unsigned ts_mask = TS_MASK;             /* defaults to 20 bits (us) */
        unsigned ts_roundbit = TS_ROUNDBIT;     /* defaults to 20 bits (us) */
@@ -187,7 +199,7 @@ main(
                                        --pll_control;
                                if (pll_control < 0)
                                        break;
-                               times[c] = ntv.time.tv_usec;
+                               times[c] = ntv.time.tv_frac_sec;
                        }
 #ifdef SIGSYS
                }
@@ -233,16 +245,18 @@ main(
        else {
                printf("ntp_gettime() returns code %d (%s)\n",
                    status, timex_state(status));
-               time_frac = ntv.time.tv_usec;
+               time_frac = ntv.time.tv_frac_sec;
 #ifdef STA_NANO
                if (flash & STA_NANO) {
-                       ntv.time.tv_usec /= 1000;
+                       ntv.time.tv_frac_sec /= 1000;
                        ts_mask = 0xfffffffc;   /* 1/2^30 */
                        ts_roundbit = 0x00000002;
                        fdigits = 9;
                }
 #endif
-               TVTOTS(&ntv.time, &ts);
+               tv.tv_sec = ntv.time.tv_sec;
+               tv.tv_usec = ntv.time.tv_frac_sec;
+               TVTOTS(&tv, &ts);
                ts.l_ui += JAN_1970;
                ts.l_uf += ts_roundbit;
                ts.l_uf &= ts_mask;