From: Bruno Haible Date: Sun, 13 Apr 2008 18:43:12 +0000 (+0200) Subject: Make truncl work on OSF/1 4.0. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2a386bb5c38d93788eb1a099efce2e81a6ff8d7;p=pspp Make truncl work on OSF/1 4.0. --- diff --git a/ChangeLog b/ChangeLog index 2988944062..58303a3c0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-04-13 Bruno Haible + + 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 * lib/unictype.h: Remove trailing comma from enumeration definitions. diff --git a/doc/posix-functions/truncl.texi b/doc/posix-functions/truncl.texi index 5e402ec268..c95179c8c4 100644 --- a/doc/posix-functions/truncl.texi +++ b/doc/posix-functions/truncl.texi @@ -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: diff --git a/lib/math.in.h b/lib/math.in.h index c2b8b81071..f500824813 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -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 diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 1e67652ff9..8bb771166b 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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]) ]) diff --git a/m4/truncl.m4 b/m4/truncl.m4 index aabd27f9b7..ad03638376 100644 --- a/m4/truncl.m4 +++ b/m4/truncl.m4 @@ -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 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 +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]) ]) diff --git a/modules/math b/modules/math index 62434f271c..f3a38dae52 100644 --- a/modules/math +++ b/modules/math @@ -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