changeset 16604:9ac8499fa137

rintf: Don't override undeclared system function on IRIX 6.5. * lib/math.in.h (rintf): Test HAVE_DECL_RINTF, not HAVE_RINTF. * m4/rintf.m4 (gl_FUNC_RINTF): Don't assume rintf() is declared when it exists. Set HAVE_DECL_RINTF. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize HAVE_DECL_RINTF, not HAVE_RINTF. * modules/math (Makefile.am): Substitute HAVE_DECL_RINTF, not HAVE_RINTF. * doc/posix-functions/rintf.texi: Mention missing declaration problem.
author Bruno Haible <bruno@clisp.org>
date Thu, 08 Mar 2012 02:27:05 +0100
parents f57d6aac15ce
children 65abd231dc80
files ChangeLog doc/posix-functions/rintf.texi lib/math.in.h m4/math_h.m4 m4/rintf.m4 modules/math
diffstat 6 files changed, 36 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-03-07  Bruno Haible  <bruno@clisp.org>
+
+	rintf: Don't override undeclared system function on IRIX 6.5.
+	* lib/math.in.h (rintf): Test HAVE_DECL_RINTF, not HAVE_RINTF.
+	* m4/rintf.m4 (gl_FUNC_RINTF): Don't assume rintf() is declared when it
+	exists. Set HAVE_DECL_RINTF.
+	* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize HAVE_DECL_RINTF, not
+	HAVE_RINTF.
+	* modules/math (Makefile.am): Substitute HAVE_DECL_RINTF, not
+	HAVE_RINTF.
+	* doc/posix-functions/rintf.texi: Mention missing declaration problem.
+
 2012-03-07  Bruno Haible  <bruno@clisp.org>
 
 	roundl: Avoid compilation error on AIX.
--- a/doc/posix-functions/rintf.texi
+++ b/doc/posix-functions/rintf.texi
@@ -10,7 +10,10 @@
 @itemize
 @item
 This function is missing on some platforms:
-Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, MSVC 9.
+Minix 3.1.8, AIX 5.1, HP-UX 11, older IRIX 6.5, Solaris 9, MSVC 9.
+@item
+This function is not declared on some platforms:
+IRIX 6.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1277,7 +1277,7 @@
 
 
 #if @GNULIB_RINTF@
-# if !@HAVE_RINTF@
+# if !@HAVE_DECL_RINTF@
 _GL_FUNCDECL_SYS (rintf, float, (float x));
 # endif
 _GL_CXXALIAS_SYS (rintf, float, (float x));
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 85
+# math_h.m4 serial 86
 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -185,7 +185,6 @@
   HAVE_REMAINDERF=1;           AC_SUBST([HAVE_REMAINDERF])
   HAVE_REMAINDERL=1;           AC_SUBST([HAVE_REMAINDERL])
   HAVE_RINT=1;                 AC_SUBST([HAVE_RINT])
-  HAVE_RINTF=1;                AC_SUBST([HAVE_RINTF])
   HAVE_RINTL=1;                AC_SUBST([HAVE_RINTL])
   HAVE_SINF=1;                 AC_SUBST([HAVE_SINF])
   HAVE_SINL=1;                 AC_SUBST([HAVE_SINL])
@@ -213,6 +212,7 @@
   HAVE_DECL_LOGL=1;            AC_SUBST([HAVE_DECL_LOGL])
   HAVE_DECL_LOG10L=1;          AC_SUBST([HAVE_DECL_LOG10L])
   HAVE_DECL_REMAINDER=1;       AC_SUBST([HAVE_DECL_REMAINDER])
+  HAVE_DECL_RINTF=1;           AC_SUBST([HAVE_DECL_RINTF])
   HAVE_DECL_ROUND=1;           AC_SUBST([HAVE_DECL_ROUND])
   HAVE_DECL_ROUNDF=1;          AC_SUBST([HAVE_DECL_ROUNDF])
   HAVE_DECL_ROUNDL=1;          AC_SUBST([HAVE_DECL_ROUNDL])
--- a/m4/rintf.m4
+++ b/m4/rintf.m4
@@ -1,4 +1,4 @@
-# rintf.m4 serial 3
+# rintf.m4 serial 4
 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,10 +12,22 @@
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
   dnl Determine RINTF_LIBM.
-  gl_MATHFUNC([rintf], [float], [(float)])
-  if test $gl_cv_func_rintf_no_libm = no \
-     && test $gl_cv_func_rintf_in_libm = no; then
+  gl_MATHFUNC([rintf], [float], [(float)],
+    [extern
+     #ifdef __cplusplus
+     "C"
+     #endif
+     float rintf (float);
+    ])
+  if test $gl_cv_func_rintf_no_libm = yes \
+     || test $gl_cv_func_rintf_in_libm = yes; then
+    HAVE_RINTF=1
+    dnl Also check whether it's declared.
+    dnl IRIX 6.5 has rintf() in libm but doesn't declare it in <math.h>.
+    AC_CHECK_DECLS([rintf], , [HAVE_DECL_RINTF=0], [[#include <math.h>]])
+  else
     HAVE_RINTF=0
+    HAVE_DECL_RINTF=0
     RINTF_LIBM=
   fi
   AC_SUBST([RINTF_LIBM])
--- a/modules/math
+++ b/modules/math
@@ -153,7 +153,6 @@
 	      -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \
 	      -e 's|@''HAVE_REMAINDERL''@|$(HAVE_REMAINDERL)|g' \
 	      -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
-	      -e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
 	      -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
 	      -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \
 	      -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
@@ -181,6 +180,7 @@
 	      -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \
 	      -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \
 	      -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \
+	      -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \
 	      -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \
 	      -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \
 	      -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \