From: Dave Hart Date: Thu, 19 May 2011 02:46:37 +0000 (+0000) Subject: [Bug 1932] libevent/util_internal.h builtin_expect compile error with X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65dbc7e5c6d432dd0020dfbd94235ea6cfec03ea;p=thirdparty%2Fntp.git [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. bk: 4dd4848dM8Zo_hfKHSWyo03pDOaSGw --- diff --git a/ChangeLog b/ChangeLog index 50659bb45b..395bc013da 100644 --- 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 * [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs. (4.2.7p168) 2011/05/16 Released by Harlan Stenn @@ -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 * If we have local overrides for autogen template files, use them. * Convert more of the sntp-opt.def documentation from man to mdoc. diff --git a/include/ntp_fp.h b/include/ntp_fp.h index d939426e4c..6b2321c5e5 100644 --- a/include/ntp_fp.h +++ b/include/ntp_fp.h @@ -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 /* 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 { \ diff --git a/sntp/libevent/util-internal.h b/sntp/libevent/util-internal.h index f4f58f1058..44d7814643 100644 --- a/sntp/libevent/util-internal.h +++ b/sntp/libevent/util-internal.h @@ -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)