From bf552416ee94157bd9aa4045b1622234fcf28e91 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 11 Oct 2011 11:15:25 +0200 Subject: [PATCH] acosl: Simplify for platforms where 'long double' == 'double'. * lib/acosl.c (acosl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative implementation. * m4/acosl.m4 (gl_FUNC_ACOSL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine ACOSL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. * modules/acosl (Depends-on): Add acos. Update conditions. --- ChangeLog | 9 +++++++++ lib/acosl.c | 12 ++++++++++++ m4/acosl.m4 | 33 ++++++++++++++++++++------------- modules/acosl | 5 +++-- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index f945f341f..01ddd60af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-10-10 Bruno Haible + acosl: Simplify for platforms where 'long double' == 'double'. + * lib/acosl.c (acosl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New + alternative implementation. + * m4/acosl.m4 (gl_FUNC_ACOSL): Require gl_LONG_DOUBLE_VS_DOUBLE. + Determine ACOSL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. + * modules/acosl (Depends-on): Add acos. Update conditions. + +2011-10-10 Bruno Haible + asinl: Simplify for platforms where 'long double' == 'double'. * lib/asinl.c (asinl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative implementation. diff --git a/lib/acosl.c b/lib/acosl.c index 260a4370e..c86463137 100644 --- a/lib/acosl.c +++ b/lib/acosl.c @@ -14,6 +14,16 @@ /* Specification. */ #include +#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +long double +acosl (long double x) +{ + return acos (x); +} + +#else + /* Long double expansions contributed by Stephen L. Moshier @@ -186,6 +196,8 @@ acosl (long double x) return 2 * asinl (sqrtl ((1 - x) / 2)); } +#endif + #if 0 int main (void) diff --git a/m4/acosl.m4 b/m4/acosl.m4 index f25ee2331..759780233 100644 --- a/m4/acosl.m4 +++ b/m4/acosl.m4 @@ -1,4 +1,4 @@ -# acosl.m4 serial 5 +# acosl.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_ACOSL], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + dnl Persuade glibc to declare acosl(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) @@ -56,18 +58,23 @@ AC_DEFUN([gl_FUNC_ACOSL], HAVE_DECL_ACOSL=0 HAVE_ACOSL=0 dnl Find libraries needed to link lib/acosl.c. - AC_REQUIRE([gl_FUNC_ASINL]) - AC_REQUIRE([gl_FUNC_SQRTL]) - dnl Append $ASINL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates. - case " $ACOSL_LIBM " in - *" $ASINL_LIBM "*) ;; - *) ACOSL_LIBM="$ACOSL_LIBM $ASINL_LIBM" ;; - esac - dnl Append $SQRTL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates. - case " $ACOSL_LIBM " in - *" $SQRTL_LIBM "*) ;; - *) ACOSL_LIBM="$ACOSL_LIBM $SQRTL_LIBM" ;; - esac + if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then + AC_REQUIRE([gl_FUNC_ACOS]) + ACOSL_LIBM="$ACOS_LIBM" + else + AC_REQUIRE([gl_FUNC_ASINL]) + AC_REQUIRE([gl_FUNC_SQRTL]) + dnl Append $ASINL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates. + case " $ACOSL_LIBM " in + *" $ASINL_LIBM "*) ;; + *) ACOSL_LIBM="$ACOSL_LIBM $ASINL_LIBM" ;; + esac + dnl Append $SQRTL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates. + case " $ACOSL_LIBM " in + *" $SQRTL_LIBM "*) ;; + *) ACOSL_LIBM="$ACOSL_LIBM $SQRTL_LIBM" ;; + esac + fi fi AC_SUBST([ACOSL_LIBM]) ]) diff --git a/modules/acosl b/modules/acosl index 65152ad3a..2ca9ebe87 100644 --- a/modules/acosl +++ b/modules/acosl @@ -8,8 +8,9 @@ m4/acosl.m4 Depends-on: math extensions -asinl [test $HAVE_ACOSL = 0] -sqrtl [test $HAVE_ACOSL = 0] +acos [test $HAVE_ACOSL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +asinl [test $HAVE_ACOSL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +sqrtl [test $HAVE_ACOSL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_ACOSL -- 2.11.0