+2020-08-09 Bruno Haible <bruno@clisp.org>
+
+ Use __builtin_isnan with clang.
+ * lib/isnanf-nolibm.h (isnanf): Use the GCC built-in __builtin_isnan,
+ not __builtin_isnanf. Also on clang.
+ * m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_ISNANF_WORKS): Use the GCC
+ built-in __builtin_isnan, not __builtin_isnanf. Also on clang.
+ * lib/isnand-nolibm.h (isnand): With clang, use the GCC built-in.
+ * m4/isnand.m4 (gl_HAVE_ISNAND_IN_LIBM): With clang, use the GCC
+ built-in.
+ * lib/isnanl-nolibm.h (isnanf): Use the GCC built-in __builtin_isnan,
+ not __builtin_isnanl. Also on clang.
+ * m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_FUNC_ISNANL_WORKS): Use the
+ GCC built-in __builtin_isnan, not __builtin_isnanl. Also on clang.
+ * lib/math.in.h (__has_builtin): Remove macro.
+ (isnanf, gl_isnan_f): Use the GCC built-in __builtin_isnan, not
+ __builtin_isnanf. Also on clang.
+ (isnand, gl_isnan_d): With clang, use the GCC built-in.
+ (isnanl, gl_isnan_l): Use the GCC built-in __builtin_isnan, not
+ __builtin_isnanl. Also on clang.
+ (isnan): Use the GCC built-in __builtin_isnan in all three cases. Also
+ on clang.
+
2020-08-09 Bruno Haible <bruno@clisp.org>
thread-optim: Fix logic error.
#if HAVE_ISNAND_IN_LIBC
/* Get declaration of isnan macro. */
# include <math.h>
-# if __GNUC__ >= 4
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */
# undef isnand
# define isnand(x) __builtin_isnan ((double)(x))
# else
#if HAVE_ISNANF_IN_LIBC
/* Get declaration of isnan macro or (older) isnanf function. */
# include <math.h>
-# ifndef __has_builtin
-# define __has_builtin(name) 0
-# endif
-# if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
+ GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */
# undef isnanf
-# define isnanf(x) __builtin_isnanf ((float)(x))
+# define isnanf(x) __builtin_isnan ((float)(x))
# elif defined isnan
# undef isnanf
# define isnanf(x) isnan ((float)(x))
#if HAVE_ISNANL_IN_LIBC
/* Get declaration of isnan macro or (older) isnanl function. */
# include <math.h>
-# ifndef __has_builtin
-# define __has_builtin(name) 0
-# endif
-# if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
+ GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */
# undef isnanl
-# define isnanl(x) __builtin_isnanl ((long double)(x))
+# define isnanl(x) __builtin_isnan ((long double)(x))
# elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
#endif
-/* For clang: Use __has_builtin to determine whether a builtin is available. */
-#ifndef __has_builtin
-# define __has_builtin(name) 0
-#endif
-
-
/* POSIX allows platforms that don't support NAN. But all major
machines in the past 15 years have supported something close to
IEEE NaN, so we define this unconditionally. We also must define
# if @HAVE_ISNANF@
/* The original <math.h> included above provides a declaration of isnan macro
or (older) isnanf function. */
-# if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
+ GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */
# undef isnanf
-# define isnanf(x) __builtin_isnanf ((float)(x))
+# define isnanf(x) __builtin_isnan ((float)(x))
# elif defined isnan
# undef isnanf
# define isnanf(x) isnan ((float)(x))
# if @HAVE_ISNAND@
/* The original <math.h> included above provides a declaration of isnan
macro. */
-# if __GNUC__ >= 4
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */
# undef isnand
# define isnand(x) __builtin_isnan ((double)(x))
# else
# if @HAVE_ISNANL@
/* The original <math.h> included above provides a declaration of isnan
macro or (older) isnanl function. */
-# if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
- /* GCC 4.0 and newer provides three built-ins for isnan. */
+# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
+ /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
+ GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */
# undef isnanl
-# define isnanl(x) __builtin_isnanl ((long double)(x))
+# define isnanl(x) __builtin_isnan ((long double)(x))
# elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
isnanf.h (e.g.) here, because those may end up being macros
that recursively expand back to isnan. So use the gnulib
replacements for them directly. */
-# if @HAVE_ISNANF@ && __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
-# define gl_isnan_f(x) __builtin_isnanf ((float)(x))
+# if @HAVE_ISNANF@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
+# define gl_isnan_f(x) __builtin_isnan ((float)(x))
# else
_GL_EXTERN_C int rpl_isnanf (float x);
# define gl_isnan_f(x) rpl_isnanf (x)
# endif
-# if @HAVE_ISNAND@ && __GNUC__ >= 4
+# if @HAVE_ISNAND@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
# define gl_isnan_d(x) __builtin_isnan ((double)(x))
# else
_GL_EXTERN_C int rpl_isnand (double x);
# define gl_isnan_d(x) rpl_isnand (x)
# endif
-# if @HAVE_ISNANL@ && __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
-# define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
+# if @HAVE_ISNANL@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
+# define gl_isnan_l(x) __builtin_isnan ((long double)(x))
# else
_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
# define gl_isnan_l(x) rpl_isnanl (x)
(sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
gl_isnan_f (x))
-# elif __GNUC__ >= 4 && (!defined __clang__ || (__has_builtin (__builtin_isnanf) && __has_builtin (__builtin_isnanl)))
+# elif (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnan
# define isnan(x) \
- (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \
+ (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \
sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
- __builtin_isnanf ((float)(x)))
+ __builtin_isnan ((float)(x)))
# endif
# ifdef __cplusplus
# if defined isnan || defined GNULIB_NAMESPACE
-# isnand.m4 serial 11
+# isnand.m4 serial 12
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #if __GNUC__ >= 4
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnand
# define isnand(x) __builtin_isnan ((double)(x))
#elif defined isnan
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #if __GNUC__ >= 4
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnand
# define isnand(x) __builtin_isnan ((double)(x))
#else
-# isnanf.m4 serial 16
+# isnanf.m4 serial 17
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #ifndef __has_builtin
- # define __has_builtin(name) 0
- #endif
- #if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanf
- # define isnanf(x) __builtin_isnanf ((float)(x))
+ # define isnanf(x) __builtin_isnan ((float)(x))
#elif defined isnan
# undef isnanf
# define isnanf(x) isnan ((float)(x))
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #ifndef __has_builtin
- # define __has_builtin(name) 0
- #endif
- #if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanf
- # define isnanf(x) __builtin_isnanf ((float)(x))
+ # define isnanf(x) __builtin_isnan ((float)(x))
#elif defined isnan
# undef isnanf
# define isnanf(x) isnan ((float)(x))
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <math.h>
-#ifndef __has_builtin
-# define __has_builtin(name) 0
-#endif
-#if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanf))
+#if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanf
-# define isnanf(x) __builtin_isnanf ((float)(x))
+# define isnanf(x) __builtin_isnan ((float)(x))
#elif defined isnan
# undef isnanf
# define isnanf(x) isnan ((float)(x))
-# isnanl.m4 serial 21
+# isnanl.m4 serial 22
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #ifndef __has_builtin
- # define __has_builtin(name) 0
- #endif
- #if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanl
- # define isnanl(x) __builtin_isnanl ((long double)(x))
+ # define isnanl(x) __builtin_isnan ((long double)(x))
#elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
- #ifndef __has_builtin
- # define __has_builtin(name) 0
- #endif
- #if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
+ #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanl
- # define isnanl(x) __builtin_isnanl ((long double)(x))
+ # define isnanl(x) __builtin_isnan ((long double)(x))
#elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))
#include <float.h>
#include <limits.h>
#include <math.h>
-#ifndef __has_builtin
-# define __has_builtin(name) 0
-#endif
-#if __GNUC__ >= 4 && (!defined __clang__ || __has_builtin (__builtin_isnanl))
+#if (__GNUC__ >= 4) || (__clang_major__ >= 4)
# undef isnanl
-# define isnanl(x) __builtin_isnanl ((long double)(x))
+# define isnanl(x) __builtin_isnan ((long double)(x))
#elif defined isnan
# undef isnanl
# define isnanl(x) isnan ((long double)(x))