changeset 16611:b0c15a5d5038

fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5. * m4/fma.m4 (gl_FUNC_FMA): If fma() exists but is not declared, arrange to set REPLACE_FMA=1, not HAVE_FMA=0. * m4/fmaf.m4 (gl_FUNC_FMAF): If fmaf() exists but is not declared, arrange to set REPLACE_FMAF=1, not HAVE_FMAF=0. * m4/fmal.m4 (gl_FUNC_FMAL): If fmal() exists but is not declared, arrange to set REPLACE_FMAL=1, not HAVE_FMAL=0.
author Bruno Haible <bruno@clisp.org>
date Thu, 08 Mar 2012 12:33:36 +0100
parents ef330e58b855
children a3a0882402d7
files ChangeLog m4/fma.m4 m4/fmaf.m4 m4/fmal.m4
diffstat 4 files changed, 64 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-03-08  Bruno Haible  <bruno@clisp.org>
+
+	fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
+	* m4/fma.m4 (gl_FUNC_FMA): If fma() exists but is not declared,
+	arrange to set REPLACE_FMA=1, not HAVE_FMA=0.
+	* m4/fmaf.m4 (gl_FUNC_FMAF): If fmaf() exists but is not declared,
+	arrange to set REPLACE_FMAF=1, not HAVE_FMAF=0.
+	* m4/fmal.m4 (gl_FUNC_FMAL): If fmal() exists but is not declared,
+	arrange to set REPLACE_FMAL=1, not HAVE_FMAL=0.
+
 2012-03-08  Bruno Haible  <bruno@clisp.org>
 
 	remainderf: Override buggy system function on IRIX 6.5.
--- a/m4/fma.m4
+++ b/m4/fma.m4
@@ -1,4 +1,4 @@
-# fma.m4 serial 1
+# fma.m4 serial 2
 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,
@@ -9,13 +9,25 @@
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
 
   dnl Determine FMA_LIBM.
-  gl_MATHFUNC([fma], [double], [(double, double, double)])
+  gl_MATHFUNC([fma], [double], [(double, double, double)],
+    [extern
+     #ifdef __cplusplus
+     "C"
+     #endif
+     double fma (double, double, double);
+    ])
   if test $gl_cv_func_fma_no_libm = yes \
      || test $gl_cv_func_fma_in_libm = yes; then
-    gl_FUNC_FMA_WORKS
-    case "$gl_cv_func_fma_works" in
-      *no) REPLACE_FMA=1 ;;
-    esac
+    dnl Also check whether it's declared.
+    dnl IRIX 6.5 has fma() in libm but doesn't declare it in <math.h>,
+    dnl and the function is buggy.
+    AC_CHECK_DECL([fma], , [REPLACE_FMA=1], [[#include <math.h>]])
+    if test $REPLACE_FMA = 0; then
+      gl_FUNC_FMA_WORKS
+      case "$gl_cv_func_fma_works" in
+        *no) REPLACE_FMA=1 ;;
+      esac
+    fi
   else
     HAVE_FMA=0
   fi
--- a/m4/fmaf.m4
+++ b/m4/fmaf.m4
@@ -1,4 +1,4 @@
-# fmaf.m4 serial 2
+# fmaf.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,13 +12,25 @@
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
   dnl Determine FMAF_LIBM.
-  gl_MATHFUNC([fmaf], [float], [(float, float, float)])
+  gl_MATHFUNC([fmaf], [float], [(float, float, float)],
+    [extern
+     #ifdef __cplusplus
+     "C"
+     #endif
+     float fmaf (float, float, float);
+    ])
   if test $gl_cv_func_fmaf_no_libm = yes \
      || test $gl_cv_func_fmaf_in_libm = yes; then
-    gl_FUNC_FMAF_WORKS
-    case "$gl_cv_func_fmaf_works" in
-      *no) REPLACE_FMAF=1 ;;
-    esac
+    dnl Also check whether it's declared.
+    dnl IRIX 6.5 has fmaf() in libm but doesn't declare it in <math.h>,
+    dnl and the function is likely buggy.
+    AC_CHECK_DECL([fmaf], , [REPLACE_FMAF=1], [[#include <math.h>]])
+    if test $REPLACE_FMAF = 0; then
+      gl_FUNC_FMAF_WORKS
+      case "$gl_cv_func_fmaf_works" in
+        *no) REPLACE_FMAF=1 ;;
+      esac
+    fi
   else
     HAVE_FMAF=0
   fi
--- a/m4/fmal.m4
+++ b/m4/fmal.m4
@@ -1,4 +1,4 @@
-# fmal.m4 serial 2
+# fmal.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,
@@ -13,13 +13,25 @@
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
   dnl Determine FMAL_LIBM.
-  gl_MATHFUNC([fmal], [long double], [(long double, long double, long double)])
+  gl_MATHFUNC([fmal], [long double], [(long double, long double, long double)],
+    [extern
+     #ifdef __cplusplus
+     "C"
+     #endif
+     long double fmal (long double, long double, long double);
+    ])
   if test $gl_cv_func_fmal_no_libm = yes \
      || test $gl_cv_func_fmal_in_libm = yes; then
-    gl_FUNC_FMAL_WORKS
-    case "$gl_cv_func_fmal_works" in
-      *no) REPLACE_FMAL=1 ;;
-    esac
+    dnl Also check whether it's declared.
+    dnl IRIX 6.5 has fmal() in libm but doesn't declare it in <math.h>,
+    dnl and the function is buggy.
+    AC_CHECK_DECL([fmal], , [REPLACE_FMAL=1], [[#include <math.h>]])
+    if test $REPLACE_FMAL = 0; then
+      gl_FUNC_FMAL_WORKS
+      case "$gl_cv_func_fmal_works" in
+        *no) REPLACE_FMAL=1 ;;
+      esac
+    fi
   else
     HAVE_FMAL=0
   fi