From 6d273f723651db3faff61a76569eb44d8750b5f1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 11 Oct 2011 02:11:21 +0200 Subject: [PATCH] logl: Simplify for platforms where 'long double' == 'double'. * lib/logl.c (logl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative implementation. * m4/logl.m4 (gl_FUNC_LOGL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine LOGL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. * modules/logl (Depends-on): Add log. Update conditions. --- ChangeLog | 9 +++++++++ lib/logl.c | 14 +++++++++++++- m4/logl.m4 | 45 ++++++++++++++++++++++++++------------------- modules/logl | 7 ++++--- 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed76156b0..7ca4425b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-10-10 Bruno Haible + logl: Simplify for platforms where 'long double' == 'double'. + * lib/logl.c (logl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative + implementation. + * m4/logl.m4 (gl_FUNC_LOGL): Require gl_LONG_DOUBLE_VS_DOUBLE. + Determine LOGL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. + * modules/logl (Depends-on): Add log. Update conditions. + +2011-10-10 Bruno Haible + expl: Simplify for platforms where 'long double' == 'double'. * lib/expl.c (expl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative implementation. diff --git a/lib/logl.c b/lib/logl.c index de46bd357..42c50cb1a 100644 --- a/lib/logl.c +++ b/lib/logl.c @@ -18,6 +18,16 @@ /* Specification. */ #include +#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +long double +logl (long double x) +{ + return log (x); +} + +#else + /* logll.c * * Natural logarithm for 128-bit long double precision. @@ -122,7 +132,7 @@ static const long double logtbl[92] = { -2.7902661731604211834685052867305795169688E-4L, -1.2335696813916860754951146082826952093496E-4L, -3.0677461025892873184042490943581654591817E-5L, -#define ZERO logtbl[38] +# define ZERO logtbl[38] 0.0000000000000000000000000000000000000000E0L, -3.0359557945051052537099938863236321874198E-5L, -1.2081346403474584914595395755316412213151E-4L, @@ -259,3 +269,5 @@ logl (long double x) y += e * ln2a; return y; } + +#endif diff --git a/m4/logl.m4 b/m4/logl.m4 index 70a5eadfc..f17e5e5f3 100644 --- a/m4/logl.m4 +++ b/m4/logl.m4 @@ -1,4 +1,4 @@ -# logl.m4 serial 5 +# logl.m4 serial 6 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,6 +7,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_LOGL], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + dnl Persuade glibc to declare logl(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) @@ -56,24 +58,29 @@ AC_DEFUN([gl_FUNC_LOGL], HAVE_DECL_LOGL=0 HAVE_LOGL=0 dnl Find libraries needed to link lib/logl.c. - AC_REQUIRE([gl_FUNC_FREXPL]) - AC_REQUIRE([gl_FUNC_ISNANL]) - AC_REQUIRE([gl_FUNC_FLOORL]) - dnl Append $FREXPL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. - case " $LOGL_LIBM " in - *" $FREXPL_LIBM "*) ;; - *) LOGL_LIBM="$LOGL_LIBM $FREXPL_LIBM" ;; - esac - dnl Append $ISNANL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. - case " $LOGL_LIBM " in - *" $ISNANL_LIBM "*) ;; - *) LOGL_LIBM="$LOGL_LIBM $ISNANL_LIBM" ;; - esac - dnl Append $FLOORL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. - case " $LOGL_LIBM " in - *" $FLOORL_LIBM "*) ;; - *) LOGL_LIBM="$LOGL_LIBM $FLOORL_LIBM" ;; - esac + if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then + AC_REQUIRE([gl_FUNC_LOG]) + LOGL_LIBM="$LOG_LIBM" + else + AC_REQUIRE([gl_FUNC_FREXPL]) + AC_REQUIRE([gl_FUNC_ISNANL]) + AC_REQUIRE([gl_FUNC_FLOORL]) + dnl Append $FREXPL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. + case " $LOGL_LIBM " in + *" $FREXPL_LIBM "*) ;; + *) LOGL_LIBM="$LOGL_LIBM $FREXPL_LIBM" ;; + esac + dnl Append $ISNANL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. + case " $LOGL_LIBM " in + *" $ISNANL_LIBM "*) ;; + *) LOGL_LIBM="$LOGL_LIBM $ISNANL_LIBM" ;; + esac + dnl Append $FLOORL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates. + case " $LOGL_LIBM " in + *" $FLOORL_LIBM "*) ;; + *) LOGL_LIBM="$LOGL_LIBM $FLOORL_LIBM" ;; + esac + fi fi AC_SUBST([LOGL_LIBM]) ]) diff --git a/modules/logl b/modules/logl index 8ed3c0f47..1f0a95688 100644 --- a/modules/logl +++ b/modules/logl @@ -8,9 +8,10 @@ m4/logl.m4 Depends-on: math extensions -frexpl [test $HAVE_LOGL = 0] -isnanl [test $HAVE_LOGL = 0] -floorl [test $HAVE_LOGL = 0] +log [test $HAVE_LOGL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +frexpl [test $HAVE_LOGL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +isnanl [test $HAVE_LOGL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +floorl [test $HAVE_LOGL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_LOGL -- 2.11.0