logl: Simplify for platforms where 'long double' == 'double'.
authorBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 00:11:21 +0000 (02:11 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 11 Oct 2011 00:11:21 +0000 (02:11 +0200)
* 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.

ChangeLog
lib/logl.c
m4/logl.m4
modules/logl

index ed76156..7ca4425 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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'.
        * lib/expl.c (expl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative
        implementation.
index de46bd3..42c50cb 100644 (file)
 /* 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 @@ static const long double logtbl[92] = {
 -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 @@ logl (long double x)
   y += e * ln2a;
   return y;
 }
+
+#endif
index 70a5ead..f17e5e5 100644 (file)
@@ -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 @@ dnl with or without modifications, as long as this notice is preserved.
 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 @@ AC_DEFUN([gl_FUNC_LOGL],
     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])
 ])
index 8ed3c0f..1f0a956 100644 (file)
@@ -8,9 +8,10 @@ m4/logl.m4
 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