bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tru64 4.0D declares round* but does not define them


From: Ben Pfaff
Subject: Re: Tru64 4.0D declares round* but does not define them
Date: Sat, 27 Oct 2007 21:09:49 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Ralf Wildenhues wrote:
>> On Tru64 4.0D, /usr/include.dtk/math.h declares round, roundf and
>> roundl, but I can't find a library that defines them.  Same thing for
>> roundf and roundl and respective tests.
>> 
>> This causes link failures for the test-round* tests:
>
> Confirmed. It affects only round*. The trunc* functions are available.
> So, for the round* functions, one needs to check whether both the declaration
> and the function exists.
>
> Ben, if you commit a tentative fix into gnulib, I can test it.

Thanks.  I committed this:

diff --git a/ChangeLog b/ChangeLog
index a3dbe42..04b696f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-10-27  Ben Pfaff  <address@hidden>
+
+       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  <address@hidden>
 
        * doc/gnulib.texi: Invoke @firstparagraphindent.
diff --git a/lib/math.in.h b/lib/math.in.h
index c5d98f0..c0f7770 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 address@hidden@
+#  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 address@hidden@
+#  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 address@hidden@
+#  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 fb9cb94..313dace 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 6e7e739..772fba3 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 <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])
diff --git a/m4/roundf.m4 b/m4/roundf.m4
index d1f4183..da3151c 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 <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
diff --git a/m4/roundl.m4 b/m4/roundl.m4
index 25ee1f8..828103c 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 <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

-- 
"To the engineer, the world is a toy box full of sub-optimized and
 feature-poor toys."
--Scott Adams




reply via email to

[Prev in Thread] Current Thread [Next in Thread]