Commit ca45caaa authored by Ben Pfaff's avatar Ben Pfaff

Check whether round* exist in libraries, not just whether they are declared.

parent 0e88f121
2007-10-27 Ben Pfaff <blp@gnu.org>
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 <bruno@clisp.org>
* doc/gnulib.texi: Invoke @firstparagraphindent.
......@@ -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
......
# 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
])
# 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 <math.h>])
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])
......
# 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 <math.h>])
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 <math.h>])
if test "$ac_cv_have_decl_floorf" = yes &&
test "$ac_cv_have_decl_ceilf" = yes; then
......
# 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 <math.h>])
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 <math.h>])
if test "$ac_cv_have_decl_floorl" = yes &&
test "$ac_cv_have_decl_ceill" = yes; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment