Mercurial > hg > octave-lyh > gnulib-hg
changeset 15938:fa7f37e4af87
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 11 Oct 2011 02:11:21 +0200 |
parents | 16cba28a5e86 |
children | 76734739cce2 |
files | ChangeLog lib/logl.c m4/logl.m4 modules/logl |
diffstat | 4 files changed, 52 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-10-10 Bruno Haible <bruno@clisp.org> + + 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 <bruno@clisp.org> expl: Simplify for platforms where 'long double' == 'double'.
--- a/lib/logl.c +++ b/lib/logl.c @@ -18,6 +18,16 @@ /* Specification. */ #include <math.h> +#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 @@ -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 @@ y += e * ln2a; return y; } + +#endif
--- 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 @@ AC_DEFUN([gl_FUNC_LOGL], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + dnl Persuade glibc <math.h> to declare logl(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) @@ -56,24 +58,29 @@ 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]) ])
--- a/modules/logl +++ b/modules/logl @@ -8,9 +8,10 @@ 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