bug-gnulib
[Top][All Lists]
Advanced

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

isnan on HP-UX with gcc


From: Bruno Haible
Subject: isnan on HP-UX with gcc
Date: Fri, 31 Dec 2010 15:04:05 +0100
User-agent: KMail/1.9.9

On HP-UX 11.11 with gcc 4.2, I'm seeing this link error:

gcc -std=gnu99  -g -O2   -o test-isnan test-isnan.o ../gllib/libgnu.a     
/usr/ccs/bin/ld: Unsatisfied symbols:
   _Isnanf (first referenced in test-isnan.o) (code)
collect2: ld returned 1 exit status
*** Error exit code 1

The reason is that the autoconf tests in isnan[fdl].m4 have determined
that the GCC built-ins for isnan can be used without linking with libm:

  S["ISNAN_LIBM"]="   "
  S["ISNAND_LIBM"]=""
  S["ISNANF_LIBM"]=""
  S["ISNANL_LIBM"]=""

but then in gnulib's <math.h> the GCC built-ins are not used. Instead,
the original definition from HP-UX's <math.h> is used, which _does_
require linking with -lm.

This patch fixes it (and uses more appropriate built-ins):


2010-12-31  Bruno Haible  <address@hidden>

        isnan: Use GCC built-ins when possible.
        * lib/math.in.h (gl_isnan_f): Use __builtin_isnanf instead of
        __builtin_isnan.
        (gl_isnan_l): Use __builtin_isnanl instead of __builtin_isnan.
        (isnan): Define using GCC built-ins for GCC >= 4.0.

--- lib/math.in.h.orig  Fri Dec 31 14:57:42 2010
+++ lib/math.in.h       Fri Dec 31 14:45:06 2010
@@ -699,7 +699,7 @@
    that recursively expand back to isnan.  So use the gnulib
    replacements for them directly. */
 #  if @HAVE_ISNANF@ && __GNUC__ >= 4
-#   define gl_isnan_f(x) __builtin_isnan ((float)(x))
+#   define gl_isnan_f(x) __builtin_isnanf ((float)(x))
 #  else
 _GL_EXTERN_C int rpl_isnanf (float x);
 #   define gl_isnan_f(x) rpl_isnanf (x)
@@ -711,7 +711,7 @@
 #   define gl_isnan_d(x) rpl_isnand (x)
 #  endif
 #  if @HAVE_ISNANL@ && __GNUC__ >= 4
-#   define gl_isnan_l(x) __builtin_isnan ((long double)(x))
+#   define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
 #  else
 _GL_EXTERN_C int rpl_isnanl (long double x);
 #   define gl_isnan_l(x) rpl_isnanl (x)
@@ -721,6 +721,12 @@
    (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
     sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
     gl_isnan_f (x))
+# elif __GNUC__ >= 4
+#  undef isnan
+#  define isnan(x) \
+   (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : 
\
+    sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
+    __builtin_isnanf ((float)(x)))
 # endif
 /* Ensure isnan is a macro.  */
 # ifndef isnan



reply via email to

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