]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1932] libevent/util_internal.h builtin_expect compile error with
authorDave Hart <hart@ntp.org>
Thu, 19 May 2011 02:46:37 +0000 (02:46 +0000)
committerDave Hart <hart@ntp.org>
Thu, 19 May 2011 02:46:37 +0000 (02:46 +0000)
  gcc 2.95.
Use 64-bit scalars in LFPTOD() and DTOLFP() on more platforms by
  conditionalizing on HAVE_U_INT64 rather than UINT64_MAX.

bk: 4dd4848dM8Zo_hfKHSWyo03pDOaSGw

ChangeLog
include/ntp_fp.h
sntp/libevent/util-internal.h

index 50659bb45b10e1b74c0c4542bb044bd63c684ab2..395bc013da571c3d10d3a4e7b88bd562fa6ee9a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+* [Bug 1932] libevent/util_internal.h builtin_expect compile error with
+  gcc 2.95.
+* Use 64-bit scalars in LFPTOD() and DTOLFP() on more platforms by
+  conditionalizing on HAVE_U_INT64 rather than UINT64_MAX.
 (4.2.7p169) 2011/05/18 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.
 (4.2.7p168) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>
@@ -8,7 +12,7 @@
 * Use acts_close() in acts_shutdown() to avoid leaving a stale lockfile
   if unpeered via runtime configuration while the modem is open.
 * Correct acts_close() test of pp->io.fd to see if it is open.
-* 4.2.7p164 documentation updates regarding 'tos orphanwait' expanded scope.
+* 4.2.7p164 documentation updates re: 'tos orphanwait' expanded scope.
 (4.2.7p166) 2011/05/13 Released by Harlan Stenn <stenn@ntp.org>
 * If we have local overrides for autogen template files, use them.
 * Convert more of the sntp-opt.def documentation from man to mdoc.
index d939426e4c5e50d9f0f884d9b522b850d044bb2c..6b2321c5e5c84eb4c4ff77b6306ca0348b568117 100644 (file)
@@ -244,22 +244,26 @@ typedef u_int32 u_fp;
 #define FRAC           4294967296.0            /* 2^32 as a double */
 
 
-#ifdef UINT64_MAX      /* use 64 bit integers if available */
+#ifdef HAVE_U_INT64    /* use 64 bit integers if available */
 
-#define M_DTOLFP(d, r_ui, r_uf)                /* double to l_fp */    \
+#include <math.h>      /* ldexp() */
+
+#define M_DTOLFP(d, r_ui, r_uf)                /* double to l_fp */ \
        do { \
-               uint64_t q_tmp; double d_tmp; \
+               double d_tmp; \
+               u_int64 q_tmp; \
                if ((d_tmp = (d)) < 0.0) \
-                       q_tmp = ~(uint64_t)ldexp(-d_tmp, 32) + 1; \
+                       q_tmp = ~(u_int64)ldexp(-d_tmp, 32) + 1; \
                else \
-                       q_tmp = (uint64_t)ldexp(d_tmp, 32); \
+                       q_tmp = (u_int64)ldexp(d_tmp, 32); \
                (r_uf) = (u_int32)q_tmp; \
                (r_ui) = (u_int32)(q_tmp >> 32); \
        } while(0)
 
 #define M_LFPTOD(r_ui, r_uf, d)                /* l_fp to double */ \
        do { \
-               uint64_t q_tmp = ((uint64_t)(r_ui) << 32) + (uint64_t)(r_uf); \
+               u_int64 q_tmp; \
+               q_tmp = ((u_int64)(r_ui) << 32) + (u_int64)(r_uf); \
                if (M_ISNEG((r_ui), (r_uf))) \
                        d = -ldexp((double)(~q_tmp + 1), -32); \
                else \
@@ -268,7 +272,7 @@ typedef u_int32 u_fp;
 
 #else /* use only 32 bit unsigned values */
 
-#define M_DTOLFP(d, r_ui, r_uf)                /* double to l_fp */    \
+#define M_DTOLFP(d, r_ui, r_uf)                /* double to l_fp */ \
        do { \
                double d_tmp; \
                if ((d_tmp = (d)) < 0) { \
@@ -284,7 +288,7 @@ typedef u_int32 u_fp;
        do { \
                u_int32 l_thi, l_tlo; \
                l_thi = (r_ui); l_tlo = (r_uf); \
-               if (M_ISNEG(l_thi, l_tlo)) {                  \
+               if (M_ISNEG(l_thi, l_tlo)) { \
                        M_NEG(l_thi, l_tlo); \
                        (d) = -((double)l_thi + (double)l_tlo / FRAC); \
                } else { \
index f4f58f1058441ce86222ec134442221fb12a459a..44d7814643e669ea625fade7257aa9520d5f194d 100644 (file)
@@ -181,7 +181,7 @@ long _evutil_weakrand(void);
 
 /* Evaluates to the same boolean value as 'p', and hints to the compiler that
  * we expect this value to be false. */
-#ifdef __GNUC__
+#if defined(__GNUC__) && __GNUC__ >= 3         /* gcc 3.0 or later */
 #define EVUTIL_UNLIKELY(p) __builtin_expect(!!(p),0)
 #else
 #define EVUTIL_UNLIKELY(p) (p)