summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-01-26 15:45:42 +0100
committerBruno Haible <bruno@clisp.org>2008-01-26 15:45:42 +0100
commit814389d96bd728c18fa658ae2ebb2ac72edd587a (patch)
treed58f080266e719fa528f8fc455c92b1c0d6117c1
parent3e4b5182b4adda8d229d96e307a44a75eda086d3 (diff)
downloadgnulib-814389d96bd728c18fa658ae2ebb2ac72edd587a.tar.gz
Use the GCC built-in __builtin_isnanl (if it works).
-rw-r--r--ChangeLog7
-rw-r--r--lib/isnanl-nolibm.h8
-rw-r--r--lib/isnanl.h8
-rw-r--r--m4/isnanl.m422
4 files changed, 36 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dd3da12f2..9218c80310 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-01-26 Bruno Haible <bruno@clisp.org>
+ * m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM,
+ gl_FUNC_ISNANL_WORKS): Test the GCC >= 4.0 built-in.
+ * lib/isnanl.h (isnanl): Use the GCC >= 4.0 built-in.
+ * lib/isnanl-nolibm.h (isnanl): Likewise.
+
+2008-01-26 Bruno Haible <bruno@clisp.org>
+
* m4/isnand.m4 (gl_FUNC_ISNAND_NO_LIBM): Test the GCC >= 4.0 built-in.
* lib/isnand.h (isnand): Use the GCC >= 4.0 built-in.
diff --git a/lib/isnanl-nolibm.h b/lib/isnanl-nolibm.h
index 77284331d7..fa29f54af7 100644
--- a/lib/isnanl-nolibm.h
+++ b/lib/isnanl-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,7 +17,11 @@
#if HAVE_ISNANL_IN_LIBC
/* Get declaration of isnan macro or (older) isnanl function. */
# include <math.h>
-# ifdef isnan
+# if __GNUC__ >= 4
+ /* GCC 4.0 and newer provides three built-ins for isnan. */
+# undef isnanl
+# define isnanl(x) __builtin_isnanl ((long double)(x))
+# elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
# endif
diff --git a/lib/isnanl.h b/lib/isnanl.h
index a79b040d58..36a733f9d2 100644
--- a/lib/isnanl.h
+++ b/lib/isnanl.h
@@ -1,5 +1,5 @@
/* Test for NaN.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,7 +17,11 @@
#if HAVE_ISNANL
/* Get declaration of isnan macro or (older) isnanl function. */
# include <math.h>
-# ifdef isnan
+# if __GNUC__ >= 4
+ /* GCC 4.0 and newer provides three built-ins for isnan. */
+# undef isnanl
+# define isnanl(x) __builtin_isnanl ((long double)(x))
+# elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
# endif
diff --git a/m4/isnanl.m4 b/m4/isnanl.m4
index a02ded78b8..c2bddc665a 100644
--- a/m4/isnanl.m4
+++ b/m4/isnanl.m4
@@ -1,5 +1,5 @@
-# isnanl.m4 serial 5
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# isnanl.m4 serial 6
+dnl Copyright (C) 2007-2008 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.
@@ -64,7 +64,10 @@ AC_DEFUN([gl_HAVE_ISNANL_NO_LIBM],
[gl_cv_func_isnanl_no_libm],
[
AC_TRY_LINK([#include <math.h>
- #ifdef isnan
+ #if __GNUC__ >= 4
+ # undef isnanl
+ # define isnanl(x) __builtin_isnanl ((long double)(x))
+ #elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
#endif
@@ -84,7 +87,10 @@ AC_DEFUN([gl_HAVE_ISNANL_IN_LIBM],
save_LIBS="$LIBS"
LIBS="$LIBS -lm"
AC_TRY_LINK([#include <math.h>
- #ifdef isnan
+ #if __GNUC__ >= 4
+ # undef isnanl
+ # define isnanl(x) __builtin_isnanl ((long double)(x))
+ #elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
#endif
@@ -98,6 +104,9 @@ AC_DEFUN([gl_HAVE_ISNANL_IN_LIBM],
dnl Test whether isnanl() recognizes all numbers which are neither finite nor
dnl infinite. This test fails e.g. on NetBSD/i386 and on glibc/ia64.
+dnl Also, the GCC >= 4.0 built-in __builtin_isnanl does not pass the tests
+dnl - for pseudo-denormals on i686 and x86_64,
+dnl - for pseudo-zeroes, unnormalized numbers, and pseudo-denormals on ia64.
AC_DEFUN([gl_FUNC_ISNANL_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
@@ -109,7 +118,10 @@ AC_DEFUN([gl_FUNC_ISNANL_WORKS],
#include <float.h>
#include <limits.h>
#include <math.h>
-#ifdef isnan
+#if __GNUC__ >= 4
+# undef isnanl
+# define isnanl(x) __builtin_isnanl ((long double)(x))
+#elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
#endif