Use the GCC built-in when available.
authorBruno Haible <bruno@clisp.org>
Sat, 26 Jan 2008 12:23:24 +0000 (13:23 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 26 Jan 2008 14:24:41 +0000 (15:24 +0100)
ChangeLog
lib/isnanf.h
m4/isnanf.m4

index 83bacd8ee4c01b721b4b258f6aaa035d79a159da..0756be850a425188fc3953460a86f1aeb81897e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-26  Bruno Haible  <bruno@clisp.org>
+
+       * m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_ISNANF_WORKS): Test the
+       GCC >= 4.0 built-in.
+       * lib/isnanf.h (isnanf): Use the GCC >= 4.0 built-in.
+
 2008-01-26  Bruno Haible  <bruno@clisp.org>
 
        Rename isnan, applicable to 'double' only, to isnand.
index 67bbfc6793fdbce19de06c20b9e625e4193bd376..774942c728e2499f9c63afd7ec67c55e1c9c0531 100644 (file)
@@ -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
 #if HAVE_ISNANF_IN_LIBC
 /* Get declaration of isnan macro or (older) isnanf function.  */
 # include <math.h>
-# ifdef isnan
+# if __GNUC__ >= 4
+   /* GCC 4.0 and newer provides three built-ins for isnan.  */
+#  undef isnanf
+#  define isnanf(x) __builtin_isnanf ((float)(x))
+# elif defined isnan
 #  undef isnanf
 #  define isnanf(x) isnan ((float)(x))
 # endif
index 388e6c049c3b53248dd903367ff25a9950af09a9..cff22369e73f33b3966e92dea153f934dd13d469 100644 (file)
@@ -1,5 +1,5 @@
-# isnanf.m4 serial 4
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# isnanf.m4 serial 5
+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.
@@ -33,7 +33,10 @@ AC_DEFUN([gl_HAVE_ISNANF_NO_LIBM],
     [gl_cv_func_isnanf_no_libm],
     [
       AC_TRY_LINK([#include <math.h>
-                   #ifdef isnan
+                   #if __GNUC__ >= 4
+                   # undef isnanf
+                   # define isnanf(x) __builtin_isnanf ((float)(x))
+                   #elif defined isnan
                    # undef isnanf
                    # define isnanf(x) isnan ((float)(x))
                    #endif
@@ -54,7 +57,10 @@ AC_DEFUN([gl_ISNANF_WORKS],
     [
       AC_TRY_RUN([
 #include <math.h>
-#ifdef isnan
+#if __GNUC__ >= 4
+# undef isnanf
+# define isnanf(x) __builtin_isnanf ((float)(x))
+#elif defined isnan
 # undef isnanf
 # define isnanf(x) isnan ((float)(x))
 #endif