From 7edecdd2223e8fd5a5ff5b4df34d249a8462932c Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sat, 20 Nov 2010 10:09:56 +0000 Subject: [PATCH] Add configure-time test for log1p disrespecting zero sign. --- configure.in | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index a2cb73aa07..e86811e88f 100644 --- a/configure.in +++ b/configure.in @@ -3372,6 +3372,10 @@ fi LIBS_SAVE=$LIBS LIBS="$LIBS $LIBM" +AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) +AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) +AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) + # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of # -0. on some architectures. AC_MSG_CHECKING(whether tanh preserves the sign of zero) @@ -3398,9 +3402,34 @@ then [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) fi -AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) -AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) -AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) +if test "$ac_cv_func_log1p" = yes +then + # On some versions of AIX, log1p(-0.) returns 0. instead of + # -0. See issue #9920. + AC_MSG_CHECKING(whether log1p drops the sign of negative zero) + AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + int main() { + /* Fail if the signs of log1p(-0.) and -0. can be + distinguished. */ + if (atan2(log1p(-0.), -1.) == atan2(-0., -1.)) + return 0; + else + return 1; + } + ]])], + [ac_cv_log1p_drops_zero_sign=no], + [ac_cv_log1p_drops_zero_sign=yes], + [ac_cv_log1p_drops_zero_sign=no])]) + AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign) +fi +if test "$ac_cv_log1p_drops_zero_sign" = yes +then + AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1, + [Define if log1p(-0.) is 0. rather than -0.]) +fi LIBS=$LIBS_SAVE -- 2.40.0