changeset 16599:281cc716033c

copysignf: Don't override undeclared system function on IRIX 6.5. * lib/math.in.h (copysignf): Test HAVE_DECL_COPYSIGNF, not HAVE_COPYSIGNF. * m4/copysignf.m4 (gl_FUNC_COPYSIGNF): Don't assume copysignf() is declared when it exists. Set HAVE_DECL_COPYSIGNF. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize HAVE_DECL_COPYSIGNF, not HAVE_COPYSIGNF. * modules/math (Makefile.am): Substitute HAVE_DECL_COPYSIGNF, not HAVE_COPYSIGNF. * doc/posix-functions/copysignf.texi: Mention missing declaration problem.
author Bruno Haible <bruno@clisp.org>
date Thu, 08 Mar 2012 00:42:49 +0100
parents dcdc513e338b
children fce13a4b73aa
files ChangeLog doc/posix-functions/copysignf.texi lib/math.in.h m4/copysignf.m4 m4/math_h.m4 modules/math
diffstat 6 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-07  Bruno Haible  <bruno@clisp.org>
+
+	copysignf: Don't override undeclared system function on IRIX 6.5.
+	* lib/math.in.h (copysignf): Test HAVE_DECL_COPYSIGNF, not
+	HAVE_COPYSIGNF.
+	* m4/copysignf.m4 (gl_FUNC_COPYSIGNF): Don't assume copysignf() is
+	declared when it exists. Set HAVE_DECL_COPYSIGNF.
+	* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize HAVE_DECL_COPYSIGNF,
+	not HAVE_COPYSIGNF.
+	* modules/math (Makefile.am): Substitute HAVE_DECL_COPYSIGNF, not
+	HAVE_COPYSIGNF.
+	* doc/posix-functions/copysignf.texi: Mention missing declaration
+	problem.
+
 2012-03-07  Jim Meyering  <meyering@redhat.com>
 
 	readtokens: add tests
--- a/doc/posix-functions/copysignf.texi
+++ b/doc/posix-functions/copysignf.texi
@@ -10,7 +10,10 @@
 @itemize
 @item
 This function is missing on some platforms:
-Minix 3.1.8, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
+Minix 3.1.8, AIX 5.1, 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
@@ -412,7 +412,7 @@
 
 
 #if @GNULIB_COPYSIGNF@
-# if !@HAVE_COPYSIGNF@
+# if !@HAVE_DECL_COPYSIGNF@
 _GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
 # endif
 _GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
--- a/m4/copysignf.m4
+++ b/m4/copysignf.m4
@@ -1,4 +1,4 @@
-# copysignf.m4 serial 2
+# copysignf.m4 serial 3
 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 COPYSIGNF_LIBM.
-  gl_MATHFUNC([copysignf], [float], [(float, float)])
-  if test $gl_cv_func_copysignf_no_libm = no \
-     && test $gl_cv_func_copysignf_in_libm = no; then
+  gl_MATHFUNC([copysignf], [float], [(float, float)],
+    [extern
+     #ifdef __cplusplus
+     "C"
+     #endif
+     float copysignf (float, float);
+    ])
+  if test $gl_cv_func_copysignf_no_libm = yes \
+     || test $gl_cv_func_copysignf_in_libm = yes; then
+    HAVE_COPYSIGNF=1
+    dnl Also check whether it's declared.
+    dnl IRIX 6.5 has copysignf() in libm but doesn't declare it in <math.h>.
+    AC_CHECK_DECL([copysignf], , [HAVE_DECL_COPYSIGNF=0], [[#include <math.h>]])
+  else
     HAVE_COPYSIGNF=0
+    HAVE_DECL_COPYSIGNF=0
     COPYSIGNF_LIBM=
   fi
   AC_SUBST([COPYSIGNF_LIBM])
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 84
+# math_h.m4 serial 85
 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,
@@ -151,7 +151,6 @@
   HAVE_CBRTF=1;                AC_SUBST([HAVE_CBRTF])
   HAVE_CBRTL=1;                AC_SUBST([HAVE_CBRTL])
   HAVE_COPYSIGN=1;             AC_SUBST([HAVE_COPYSIGN])
-  HAVE_COPYSIGNF=1;            AC_SUBST([HAVE_COPYSIGNF])
   HAVE_COPYSIGNL=1;            AC_SUBST([HAVE_COPYSIGNL])
   HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
@@ -203,6 +202,7 @@
   HAVE_DECL_CBRTL=1;           AC_SUBST([HAVE_DECL_CBRTL])
   HAVE_DECL_CEILF=1;           AC_SUBST([HAVE_DECL_CEILF])
   HAVE_DECL_CEILL=1;           AC_SUBST([HAVE_DECL_CEILL])
+  HAVE_DECL_COPYSIGNF=1;       AC_SUBST([HAVE_DECL_COPYSIGNF])
   HAVE_DECL_COSL=1;            AC_SUBST([HAVE_DECL_COSL])
   HAVE_DECL_EXPL=1;            AC_SUBST([HAVE_DECL_EXPL])
   HAVE_DECL_FLOORF=1;          AC_SUBST([HAVE_DECL_FLOORF])
--- a/modules/math
+++ b/modules/math
@@ -119,7 +119,6 @@
 	      -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \
 	      -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \
 	      -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
-	      -e 's|@''HAVE_COPYSIGNF''@|$(HAVE_COPYSIGNF)|g' \
 	      -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \
 	      -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
 	      -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
@@ -171,6 +170,7 @@
 	      -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \
 	      -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \
 	      -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \
+	      -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \
 	      -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \
 	      -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \
 	      -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \