Make truncl work on OSF/1 4.0.
authorBruno Haible <bruno@clisp.org>
Sun, 13 Apr 2008 18:43:12 +0000 (20:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Apr 2008 18:43:12 +0000 (20:43 +0200)
ChangeLog
doc/posix-functions/truncl.texi
lib/math.in.h
m4/math_h.m4
m4/truncl.m4
modules/math

index 2988944..58303a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-04-13  Bruno Haible  <bruno@clisp.org>
 
+       Make truncl work on OSF/1 4.0.
+       * m4/truncl.m4 (gl_FUNC_TRUNCL): Test whether truncl actually works.
+       Set REPLACE_TRUNCL, not HAVE_DECL_TRUNCL.
+       * lib/math.in.h (truncl): Test REPLACE_TRUNCL, not HAVE_DECL_TRUNCL.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_TRUNCL, not
+       HAVE_DECL_TRUNCL.
+       * modules/math (Makefile.am): Substitute REPLACE_TRUNCL, not
+       HAVE_DECL_TRUNCL.
+       * doc/posix-functions/truncl.texi: Document the OSF/1 4.0 problem.
+
+2008-04-13  Bruno Haible  <bruno@clisp.org>
+
        * lib/unictype.h: Remove trailing comma from enumeration definitions.
 
 2008-04-13  Bruno Haible  <bruno@clisp.org>
index 5e402ec..c95179c 100644 (file)
@@ -11,6 +11,9 @@ Portability problems fixed by Gnulib:
 @item
 This function is missing on some platforms:
 FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS.
+@item
+This function crashes on some platforms:
+OSF/1 4.0.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index c2b8b81..f500824 100644 (file)
@@ -351,7 +351,8 @@ extern double trunc (double x);
 #endif
 
 #if @GNULIB_TRUNCL@
-# if !@HAVE_DECL_TRUNCL@
+# if @REPLACE_TRUNCL@
+#  undef truncl
 #  define truncl rpl_truncl
 extern long double truncl (long double x);
 # endif
index 1e67652..8bb7711 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 11
+# math_h.m4 serial 12
 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -74,7 +74,6 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_DECL_TANL=1;            AC_SUBST([HAVE_DECL_TANL])
   HAVE_DECL_TRUNC=1;           AC_SUBST([HAVE_DECL_TRUNC])
   HAVE_DECL_TRUNCF=1;          AC_SUBST([HAVE_DECL_TRUNCF])
-  HAVE_DECL_TRUNCL=1;          AC_SUBST([HAVE_DECL_TRUNCL])
   REPLACE_CEILF=0;             AC_SUBST([REPLACE_CEILF])
   REPLACE_CEILL=0;             AC_SUBST([REPLACE_CEILL])
   REPLACE_FLOORF=0;            AC_SUBST([REPLACE_FLOORF])
@@ -90,4 +89,5 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_ROUNDL=0;            AC_SUBST([REPLACE_ROUNDL])
   REPLACE_SIGNBIT=0;           AC_SUBST([REPLACE_SIGNBIT])
   REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
+  REPLACE_TRUNCL=0;            AC_SUBST([REPLACE_TRUNCL])
 ])
index aabd27f..ad03638 100644 (file)
@@ -1,5 +1,5 @@
-# truncl.m4 serial 1
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# truncl.m4 serial 2
+dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_TRUNCL],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   dnl Persuade glibc <math.h> to declare truncl().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   dnl Test whether truncl() is declared.
@@ -38,11 +39,34 @@ AC_DEFUN([gl_FUNC_TRUNCL],
     if test "$TRUNCL_LIBM" = "?"; then
       TRUNCL_LIBM=
     fi
+    dnl Test whether truncl() works. It crashes on OSF/1 4.0d.
+    AC_CACHE_CHECK([whether truncl works], [gl_cv_func_truncl_works],
+      [
+        AC_TRY_RUN([
+#include <math.h>
+long double x;
+int main()
+{
+  x = truncl (0.0L);
+  return 0;
+}], [gl_cv_func_truncl_works=yes], [gl_cv_func_truncl_works=no],
+          [case "$host_os" in
+             osf4*) gl_cv_func_truncl_works="guessing no";;
+             *)     gl_cv_func_truncl_works="guessing yes";;
+           esac
+          ])
+      ])
+    case "$gl_cv_func_truncl_works" in
+      *yes) ;;
+      *) REPLACE_TRUNCL=1 ;;
+    esac
   else
-    HAVE_DECL_TRUNCL=0
+    REPLACE_TRUNCL=1
+  fi
+  if test $REPLACE_TRUNCL = 1; then
     AC_LIBOBJ([truncl])
     TRUNCL_LIBM=
   fi
-  AC_SUBST([HAVE_DECL_TRUNCL])
+  AC_SUBST([REPLACE_TRUNCL])
   AC_SUBST([TRUNCL_LIBM])
 ])
index 62434f2..f3a38da 100644 (file)
@@ -51,7 +51,6 @@ math.h: math.in.h
              -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
              -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
              -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
-             -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
              -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
              -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
              -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \
@@ -67,6 +66,7 @@ math.h: math.in.h
              -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
              -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
              -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
+             -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/math.in.h; \
        } > $@-t