]> Savannah Git Hosting - gnulib.git/commitdiff
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 f945f341f6fed48fe7b88a49eddaef1f098c790d..01ddd60af286ac908f9c2b9a57f4e7e9b4e30799 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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'.
index 260a4370eb89462f1594576968071cafb991dca7..c8646313772ee672f99e781620fed5e3a29c3912 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 f25ee2331305f7bb4e7862a52c7f302c5e9d336a..759780233cce35b3537a5f365c44bc67152814fa 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 65152ad3a0f00c042afa2c7b964eb849e271e560..2ca9ebe8759d409305df7d06055bbe5035cf391d 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