]> Savannah Git Hosting - gnulib.git/commitdiff
cbrtf: Work around bug in IRIX 6.5 system function.
authorBruno Haible <bruno@clisp.org>
Thu, 1 Mar 2012 02:36:14 +0000 (03:36 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 1 Mar 2012 02:36:14 +0000 (03:36 +0100)
* lib/math.in.h (cbrtf): Override if REPLACE_CBRTF is 1.
* m4/cbrtf.m4 (gl_FUNC_CBRTF_WORKS): New macro.
(gl_FUNC_CBRTF): Invoke it. Set REPLACE_CBRTF to 1 if cbrtf() does not
work.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_CBRTF.
* modules/math (Makefile.am): Substitute REPLACE_CBRTF.
* modules/cbrtf (configure.ac): Consider REPLACE_CBRTF.
(Depends-on): Update conditions.
* doc/posix-functions/cbrtf.texi: Mention the IRIX 6.5 problem.

ChangeLog
doc/posix-functions/cbrtf.texi
lib/math.in.h
m4/cbrtf.m4
m4/math_h.m4
modules/cbrtf
modules/math

index bce2fa1e4e2114ffb4eebcb79ef4aa0b292d17ae..6f6dbbada84be7b479c8e7981abe03e01c48df64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-02-29  Bruno Haible  <bruno@clisp.org>
+
+       cbrtf: Work around bug in IRIX 6.5 system function.
+       * lib/math.in.h (cbrtf): Override if REPLACE_CBRTF is 1.
+       * m4/cbrtf.m4 (gl_FUNC_CBRTF_WORKS): New macro.
+       (gl_FUNC_CBRTF): Invoke it. Set REPLACE_CBRTF to 1 if cbrtf() does not
+       work.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_CBRTF.
+       * modules/math (Makefile.am): Substitute REPLACE_CBRTF.
+       * modules/cbrtf (configure.ac): Consider REPLACE_CBRTF.
+       (Depends-on): Update conditions.
+       * doc/posix-functions/cbrtf.texi: Mention the IRIX 6.5 problem.
+
 2012-02-29  Bruno Haible  <bruno@clisp.org>
 
        Tests for module 'cbrtl'.
index 1794bb39673557fcb9130030aa5bd2e603e5511e..77bcc269a6dcaeca615d85f305b11ea06e356eff 100644 (file)
@@ -14,6 +14,9 @@ Minix 3.1.8, AIX 5.1, Solaris 9, MSVC 9.
 @item
 This function is not declared on some platforms:
 IRIX 6.5.
+@item
+This function returns a wrong value for a minus zero on some platforms:
+IRIX 6.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index e435c7f32ec155181ab869749758ae80e5bb9917..b359df9bbccbb8c81224069caad82dff1ef861e6 100644 (file)
@@ -289,10 +289,19 @@ _GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
 
 
 #if @GNULIB_CBRTF@
-# if !@HAVE_DECL_CBRTF@
+# if @REPLACE_CBRTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef cbrtf
+#   define cbrtf rpl_cbrtf
+#  endif
+_GL_FUNCDECL_RPL (cbrtf, float, (float x));
+_GL_CXXALIAS_RPL (cbrtf, float, (float x));
+# else
+#  if !@HAVE_DECL_CBRTF@
 _GL_FUNCDECL_SYS (cbrtf, float, (float x));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (cbrtf, float, (float x));
+# endif
 _GL_CXXALIASWARN (cbrtf);
 #elif defined GNULIB_POSIXCHECK
 # undef cbrtf
index cf2c6b74cdafebe76c5e8d3bac96164aa42b7e3a..f948bd49482dbf8cc69d67000fb188566ec6529f 100644 (file)
@@ -1,4 +1,4 @@
-# cbrtf.m4 serial 1
+# cbrtf.m4 serial 2
 dnl Copyright (C) 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,
@@ -20,9 +20,19 @@ AC_DEFUN([gl_FUNC_CBRTF],
     dnl Also check whether it's declared.
     dnl IRIX 6.5 has cbrtf() in libm but doesn't declare it in <math.h>.
     AC_CHECK_DECL([cbrtf], , [HAVE_DECL_CBRTF=0], [[#include <math.h>]])
+    save_LIBS="$LIBS"
+    LIBS="$LIBS $CBRTF_LIBM"
+    gl_FUNC_CBRTF_WORKS
+    LIBS="$save_LIBS"
+    case "$gl_cv_func_cbrtf_works" in
+      *yes) ;;
+      *) REPLACE_CBRTF=1 ;;
+    esac
   else
     HAVE_CBRTF=0
     HAVE_DECL_CBRTF=0
+  fi
+  if test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1; then
     dnl Find libraries needed to link lib/cbrtf.c.
     AC_REQUIRE([gl_FUNC_FABSF])
     AC_REQUIRE([gl_FUNC_FREXPF])
@@ -46,3 +56,41 @@ AC_DEFUN([gl_FUNC_CBRTF],
   fi
   AC_SUBST([CBRTF_LIBM])
 ])
+
+dnl Test whether cbrtf() works.
+dnl It returns wrong values on IRIX 6.5.
+AC_DEFUN([gl_FUNC_CBRTF_WORKS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether cbrtf works], [gl_cv_func_cbrtf_works],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <math.h>
+volatile float x;
+volatile float y;
+int main ()
+{
+  extern
+  #ifdef __cplusplus
+  "C"
+  #endif
+  float cbrtf (float);
+  /* This test fails on IRIX 6.5.  */
+  x = - 0.0f;
+  y = cbrtf (x);
+  if (!(y == 0.0f))
+    return 1;
+  return 0;
+}
+]])],
+        [gl_cv_func_cbrtf_works=yes],
+        [gl_cv_func_cbrtf_works=no],
+        [case "$host_os" in
+           irix*) gl_cv_func_cbrtf_works="guessing no";;
+           *)     gl_cv_func_cbrtf_works="guessing yes";;
+         esac
+        ])
+    ])
+])
index d427c1a90b4b50fc1a4a521c1e0bf28baab25e68..f329a8aca46624b6f7c1d41fc61814a9f553b2a8 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 77
+# math_h.m4 serial 78
 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,
@@ -216,6 +216,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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_CBRTF=0;             AC_SUBST([REPLACE_CBRTF])
   REPLACE_CEIL=0;              AC_SUBST([REPLACE_CEIL])
   REPLACE_CEILF=0;             AC_SUBST([REPLACE_CEILF])
   REPLACE_CEILL=0;             AC_SUBST([REPLACE_CEILL])
index 8de0368bd0d3f7c491dcc1316ff403f3348ad898..06d2b7662f10e9c4ef32ec9fd0dc09e220e81154 100644 (file)
@@ -9,14 +9,14 @@ m4/mathfunc.m4
 
 Depends-on:
 math
-isfinite        [test $HAVE_CBRTF = 0]
-fabsf           [test $HAVE_CBRTF = 0]
-frexpf          [test $HAVE_CBRTF = 0]
-ldexpf          [test $HAVE_CBRTF = 0]
+isfinite        [test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1]
+fabsf           [test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1]
+frexpf          [test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1]
+ldexpf          [test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1]
 
 configure.ac:
 gl_FUNC_CBRTF
-if test $HAVE_CBRTF = 0; then
+if test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1; then
   AC_LIBOBJ([cbrtf])
 fi
 gl_MATH_MODULE_INDICATOR([cbrtf])
index 36b05e482bab213fef8526ee613c120b8fdcb061..41505d2f80d47a7134c48bb69f2bc9db730a988a 100644 (file)
@@ -185,7 +185,8 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
              -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
          | \
-         sed -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
+         sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
+             -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
              -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
              -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
              -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \