Hal, I've enclosed the should-be-working-but-isn't scalarization patch
for l_fp.  This is the one that passes unit tests but stalls the
protocol machine in INIT.

(Another reason I didn't mention for wanting this done is that neither
of the languages we might move to has the equivalent of C unions, so I'm
trying to clean unions out of the code. This is the last essential one.)

I have to pay attention to my meatspace life tomorrow - medical
damn-I-hate-needles appointment and some other things. If you
have time, please do the diagnostic thing you were suggesting to me.
(You'll probably do it better than I would, anyway.)

I'll be back at work on Thursday.
-- 
                <a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>
diff --git a/include/ntp_fp.h b/include/ntp_fp.h
index 76e4e89..68a757e 100644
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -29,39 +29,32 @@
  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
  */
-typedef struct {
-       union {
-               uint32_t Xl_ui;         /* unsigned integral part */
-               int32_t Xl_i;           /* signed integral part */
-       } Ul_i;
-       uint32_t        l_uf;
-} l_fp;
-
-#define lfpfrac(n)             ((n).l_uf)
-#define setlfpfrac(n, v)       (n).l_uf = (v)
-#define lfpsint(n)             (n).Ul_i.Xl_i
-#define setlfpsint(n, v)       (n).Ul_i.Xl_i = (v)
-#define bumplfpsint(n, i)      (n).Ul_i.Xl_i += (i)
-#define lfpuint(n)             (n).Ul_i.Xl_ui
-#define setlfpuint(n, v)       (n).Ul_i.Xl_ui = (v)
-#define bumplfpuint(n, i)      (n).Ul_i.Xl_ui += (i)
+typedef uint64_t l_fp;
+#define LOW32  0x00000000ffffffffUL
+#define HIGH32 0xffffffff00000000UL
+#define BUMP   0x0000000100000000UL
+#define lfpfrac(n)             ((uint32_t)((n) & LOW32))
+#define setlfpfrac(n, v)       (n) = (((n) & HIGH32) | ((v) & LOW32))
+#define lfpsint(n)             (int32_t)(((n) & HIGH32) >> 32)
+#define setlfpsint(n, v)       (n) = (int64_t)((((int64_t)(v)) << 32) | ((n) & 
LOW32))
+#define bumplfpsint(n, i)      (n) += (i)*BUMP
+#define lfpuint(n)             (uint32_t)(((n) & HIGH32) >> 32)
+#define setlfpuint(n, v)       (n) = (uint64_t)((((uint64_t)(v)) << 32) | ((n) 
& LOW32))
+#define bumplfpuint(n, i)      (n) += (i)*BUMP
 
 static inline uint64_t lfp_to_uint64(const l_fp lfp)
 {
-    return (uint64_t)lfpuint(lfp) << 32 | (uint64_t)lfpfrac(lfp);
+    return lfp;
 }
 
 static inline l_fp uint64_to_lfp(uint64_t x)
 {
-    l_fp fp;
-    setlfpuint(fp, x >> 32);
-    setlfpfrac(fp, x & 0xFFFFFFFFUL);
-    return fp;
+    return x;
 }
 
 static inline l_fp lfpinit(int32_t hi, uint32_t lo)
 {
-    l_fp tmp;
+    l_fp tmp = 0;
     setlfpsint(tmp, hi);
     setlfpfrac(tmp, lo);
     return tmp;
diff --git a/libntp/refidsmear.c b/libntp/refidsmear.c
index 96e1bcc..ce3ed51 100644
--- a/libntp/refidsmear.c
+++ b/libntp/refidsmear.c
@@ -17,7 +17,7 @@
 l_fp
 convertRefIDToLFP(uint32_t r)
 {
-       l_fp temp;
+       l_fp temp = 0;
 
        r = ntohl(r);
 
_______________________________________________
devel mailing list
[email protected]
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to