acosl: Simplify for platforms where 'long double' == 'double'.
authorBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 09:15:25 +0000 (11:15 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 09:15:25 +0000 (11:15 +0200)
* 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
lib/acosl.c
m4/acosl.m4
modules/acosl

index f945f34..01ddd60 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-10-10  Bruno Haible  <bruno@clisp.org>
 
+       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  <bruno@clisp.org>
+
        asinl: Simplify for platforms where 'long double' == 'double'.
        * lib/asinl.c (asinl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New
        alternative implementation.
index 260a437..c864631 100644 (file)
 /* Specification.  */
 #include <math.h>
 
+#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 <moshier@na-net.ornl.gov>
@@ -186,6 +196,8 @@ acosl (long double x)
     return 2 * asinl (sqrtl ((1 - x) / 2));
 }
 
+#endif
+
 #if 0
 int
 main (void)
index f25ee23..7597802 100644 (file)
@@ -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 <math.h> 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])
 ])
index 65152ad..2ca9ebe 100644 (file)
@@ -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