Mercurial > hg > octave-kai > gnulib-hg
changeset 16538:06da3fa23cf9
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 01 Mar 2012 03:36:14 +0100 (2012-03-01) |
parents | c828c5d93899 |
children | f871b9a7d976 |
files | ChangeLog doc/posix-functions/cbrtf.texi lib/math.in.h m4/cbrtf.m4 m4/math_h.m4 modules/cbrtf modules/math |
diffstat | 7 files changed, 85 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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'.
--- a/doc/posix-functions/cbrtf.texi +++ b/doc/posix-functions/cbrtf.texi @@ -14,6 +14,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:
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -289,10 +289,19 @@ #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 +_GL_CXXALIAS_SYS (cbrtf, float, (float x)); # endif -_GL_CXXALIAS_SYS (cbrtf, float, (float x)); _GL_CXXALIASWARN (cbrtf); #elif defined GNULIB_POSIXCHECK # undef cbrtf
--- a/m4/cbrtf.m4 +++ b/m4/cbrtf.m4 @@ -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 @@ 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 @@ 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 + ]) + ]) +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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 @@ 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])
--- a/modules/cbrtf +++ b/modules/cbrtf @@ -9,14 +9,14 @@ 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])
--- a/modules/math +++ b/modules/math @@ -185,7 +185,8 @@ -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' \