-/* Test for NaN that does not need libm.
+/* Test for NaN.
Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#if HAVE_ISNAND_IN_LIBC
+#if HAVE_ISNAND
/* Get declaration of isnan macro. */
# include <math.h>
-# ifdef isnan
+# if __GNUC__ >= 4
+ /* GCC 4.0 and newer provides three built-ins for isnan. */
+# undef isnand
+# define isnand(x) __builtin_isnan ((double)(x))
+# else
# undef isnand
# define isnand(x) isnan ((double)(x))
# endif