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 83bacd8..0756be8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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.
        * modules/isnand-nolibm: Renamed from modules/isnan-nolibm.
        (Files): Add lib/isnand.h, lib/isnand.c. Remove lib/isnan.h.
index 67bbfc6..774942c 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 388e6c0..cff2236 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