atanl: Simplify for platforms where 'long double' == 'double'.
authorBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 09:15:59 +0000 (11:15 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 09:15:59 +0000 (11:15 +0200)
* lib/atanl.c (atanl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New
alternative implementation.
* m4/atanl.m4 (gl_FUNC_ATANL): Require gl_LONG_DOUBLE_VS_DOUBLE.
Determine ATANL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
* modules/atanl (Depends-on): Add atan. Update conditions.

ChangeLog
lib/atanl.c
m4/atanl.m4
modules/atanl

index 01ddd60..702c1fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-10-10  Bruno Haible  <bruno@clisp.org>
 
+       atanl: Simplify for platforms where 'long double' == 'double'.
+       * lib/atanl.c (atanl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New
+       alternative implementation.
+       * m4/atanl.m4 (gl_FUNC_ATANL): Require gl_LONG_DOUBLE_VS_DOUBLE.
+       Determine ATANL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
+       * modules/atanl (Depends-on): Add atan. Update conditions.
+
+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.
index 22a882d..4d09c2f 100644 (file)
 /* Specification.  */
 #include <math.h>
 
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+long double
+atanl (long double x)
+{
+  return atan (x);
+}
+
+#else
+
 /*                                                      s_atanl.c
  *
  *      Inverse circular tangent for 128-bit long double precision
@@ -222,3 +232,5 @@ atanl (long double x)
   else
     return u;
 }
+
+#endif
index 82c9cd4..330ad77 100644 (file)
@@ -1,4 +1,4 @@
-# atanl.m4 serial 5
+# atanl.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_ATANL],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+
   dnl Persuade glibc <math.h> to declare atanl().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
@@ -56,12 +58,17 @@ AC_DEFUN([gl_FUNC_ATANL],
     HAVE_DECL_ATANL=0
     HAVE_ATANL=0
     dnl Find libraries needed to link lib/atanl.c.
-    AC_REQUIRE([gl_FUNC_ISNANL])
-    dnl Append $ISNANL_LIBM to ATANL_LIBM, avoiding gratuitous duplicates.
-    case " $ATANL_LIBM " in
-      *" $ISNANL_LIBM "*) ;;
-      *) ATANL_LIBM="$ATANL_LIBM $ISNANL_LIBM" ;;
-    esac
+    if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+      AC_REQUIRE([gl_FUNC_ATAN])
+      ATANL_LIBM="$ATAN_LIBM"
+    else
+      AC_REQUIRE([gl_FUNC_ISNANL])
+      dnl Append $ISNANL_LIBM to ATANL_LIBM, avoiding gratuitous duplicates.
+      case " $ATANL_LIBM " in
+        *" $ISNANL_LIBM "*) ;;
+        *) ATANL_LIBM="$ATANL_LIBM $ISNANL_LIBM" ;;
+      esac
+    fi
   fi
   AC_SUBST([ATANL_LIBM])
 ])
index 1fd0d9a..a600846 100644 (file)
@@ -8,7 +8,8 @@ m4/atanl.m4
 Depends-on:
 math
 extensions
-isnanl          [test $HAVE_ATANL = 0]
+atan            [test $HAVE_ATANL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+isnanl          [test $HAVE_ATANL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
 
 configure.ac:
 gl_FUNC_ATANL