From ca45caaa07c9e69f791a8e93199aeafa181e7572 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 27 Oct 2007 21:05:58 -0700 Subject: [PATCH] Check whether round* exist in libraries, not just whether they are declared. --- ChangeLog | 15 +++++++++++++++ lib/math.in.h | 3 +++ m4/check-math-lib.m4 | 17 ++++++++--------- m4/round.m4 | 5 +++-- m4/roundf.m4 | 5 +++-- m4/roundl.m4 | 5 +++-- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3dbe42102..04b696f296 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-10-27 Ben Pfaff + + Ralf Wildenhues reported that Tru64 4.0D declares the round + functions but does not have definitions. + * m4/check-math-lib.m4 (gl_CHECK_MATH_LIB): If the target function + cannot be found in any library, set the output variable to + "missing" instead of "". + * m4/round.m4: Also use our substitute if we cannot find round in + any library, even if it is declared. + * m4/roundf.m4: Likewise for roundf. + * m4/roundl.m4: Likewise for roundl. + * lib/math.in.h: Undefine roundf, round, roundl before defining + their replacements, to allow for hypothetical systems where these + may be defined as macros but not available in libraries. + 2007-10-27 Bruno Haible * doc/gnulib.texi: Invoke @firstparagraphindent. diff --git a/lib/math.in.h b/lib/math.in.h index c5d98f0091..c0f77705b8 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -219,6 +219,7 @@ extern long double logl (long double x); #if @GNULIB_ROUNDF@ # if !@HAVE_DECL_ROUNDF@ +# undef roundf # define roundf rpl_roundf extern float roundf (float x); # endif @@ -233,6 +234,7 @@ extern float roundf (float x); #if @GNULIB_ROUND@ # if !@HAVE_DECL_ROUND@ +# undef round # define round rpl_round extern double round (double x); # endif @@ -247,6 +249,7 @@ extern double round (double x); #if @GNULIB_ROUNDL@ # if !@HAVE_DECL_ROUNDL@ +# undef roundl # define roundl rpl_roundl extern long double roundl (long double x); # endif diff --git a/m4/check-math-lib.m4 b/m4/check-math-lib.m4 index fb9cb94454..313dace5fb 100644 --- a/m4/check-math-lib.m4 +++ b/m4/check-math-lib.m4 @@ -1,18 +1,20 @@ -# check-math-lib.m4 serial 1 +# check-math-lib.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -dnl AC_CHECK_MATH_LIB (VARIABLE, EXPRESSION) +dnl gl_CHECK_MATH_LIB (VARIABLE, EXPRESSION) dnl -dnl Checks whether EXPRESSION requires -lm to compile and link. If so, sets -dnl the shell VARIABLE to -lm, otherwise to the empty string. +dnl Sets the shell VARIABLE according to the libraries needed by EXPRESSION +dnl to compile and link: to the empty string if no extra libraries are needed, +dnl to "-lm" if -lm is needed, or to "missing" if it does not compile and +dnl link either way. dnl -dnl Example: AC_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);]) +dnl Example: gl_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);]) AC_DEFUN([gl_CHECK_MATH_LIB], [ save_LIBS=$LIBS - $1=? + $1=missing for libm in "" "-lm"; do LIBS="$save_LIBS $libm" AC_TRY_LINK([ @@ -26,7 +28,4 @@ AC_DEFUN([gl_CHECK_MATH_LIB], [ break]) done LIBS=$save_LIBS - if test "$$1" = "?"; then - $1= - fi ]) diff --git a/m4/round.m4 b/m4/round.m4 index 6e7e739d18..772fba3a5b 100644 --- a/m4/round.m4 +++ b/m4/round.m4 @@ -1,4 +1,4 @@ -# round.m4 serial 2 +# round.m4 serial 3 dnl Copyright (C) 2007 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,7 +12,8 @@ AC_DEFUN([gl_FUNC_ROUND], AC_CHECK_DECLS([round], , , [#include ]) if test "$ac_cv_have_decl_round" = yes; then gl_CHECK_MATH_LIB([ROUND_LIBM], [x = round (x);]) - else + fi + if test "$ac_cv_have_decl_round" != yes || test "$ROUND_LIBM" = missing; then gl_CHECK_MATH_LIB([ROUND_LIBM], [x = floor (x) + ceil (x);]) HAVE_DECL_ROUND=0 AC_LIBOBJ([round]) diff --git a/m4/roundf.m4 b/m4/roundf.m4 index d1f4183760..da3151caa2 100644 --- a/m4/roundf.m4 +++ b/m4/roundf.m4 @@ -1,4 +1,4 @@ -# roundf.m4 serial 2 +# roundf.m4 serial 3 dnl Copyright (C) 2007 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,7 +12,8 @@ AC_DEFUN([gl_FUNC_ROUNDF], AC_CHECK_DECLS([roundf], , , [#include ]) if test "$ac_cv_have_decl_roundf" = yes; then gl_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);]) - else + fi + if test "$ac_cv_have_decl_roundf" != yes || test "$ROUNDF_LIBM" = missing; then AC_CHECK_DECLS([ceilf, floorf], , , [#include ]) if test "$ac_cv_have_decl_floorf" = yes && test "$ac_cv_have_decl_ceilf" = yes; then diff --git a/m4/roundl.m4 b/m4/roundl.m4 index 25ee1f8f83..828103cd46 100644 --- a/m4/roundl.m4 +++ b/m4/roundl.m4 @@ -1,4 +1,4 @@ -# roundl.m4 serial 2 +# roundl.m4 serial 3 dnl Copyright (C) 2007 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,7 +12,8 @@ AC_DEFUN([gl_FUNC_ROUNDL], AC_CHECK_DECLS([roundl], , , [#include ]) if test "$ac_cv_have_decl_roundl" = yes; then gl_CHECK_MATH_LIB([ROUNDL_LIBM], [x = roundl (x);]) - else + fi + if test "$ac_cv_have_decl_roundl" != yes || test "$ROUNDL_LIBM" = missing; then AC_CHECK_DECLS([ceill, floorl], , , [#include ]) if test "$ac_cv_have_decl_floorl" = yes && test "$ac_cv_have_decl_ceill" = yes; then -- 2.30.2