Check whether round* exist in libraries, not just whether they are declared.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Oct 2007 04:05:58 +0000 (21:05 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Oct 2007 04:05:58 +0000 (21:05 -0700)
ChangeLog
lib/math.in.h
m4/check-math-lib.m4
m4/round.m4
m4/roundf.m4
m4/roundl.m4

index a3dbe42..04b696f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
index c5d98f0..c0f7770 100644 (file)
@@ -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
index fb9cb94..313dace 100644 (file)
@@ -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
 ])
index 6e7e739..772fba3 100644 (file)
@@ -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 <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])
index d1f4183..da3151c 100644 (file)
@@ -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 <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
index 25ee1f8..828103c 100644 (file)
@@ -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 <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