]> Savannah Git Hosting - gnulib.git/commitdiff
Use __builtin_isnan with clang.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2020 10:09:17 +0000 (12:09 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2020 10:09:17 +0000 (12:09 +0200)
* 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.

ChangeLog
lib/isnand-nolibm.h
lib/isnanf-nolibm.h
lib/isnanl-nolibm.h
lib/math.in.h
m4/isnand.m4
m4/isnanf.m4
m4/isnanl.m4

index ab4cc112d232cea3fce0c12ce27ffcf0aa6e079a..c7fe4cae174d8be8236f57ab4b86cf45b168b14e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+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.
index cbabed4c10cab384be3ffffd5998929f56f10e59..b3003c6ea3b0d8a481f2ec5eccf6b15da19acae7 100644 (file)
@@ -17,8 +17,8 @@
 #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
index 17a2f5e0c3b39c9c5e719629a62b145173010ce4..be1f8b88fdf0bbbf29c6b88c6e318c094be7aacf 100644 (file)
 #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))
index 103d31a7066c987d05d27c54052757e29bd331c2..927918ca664a1133e7a2d006b0910abc0206b210 100644 (file)
 #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))
index 30465f8b2efd85c721185f691d79b3e3718bf7e7..10514f17351dcd0b1551a9a1ec17fae0139b90c7 100644 (file)
@@ -127,12 +127,6 @@ static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq;
 #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
@@ -2324,10 +2318,11 @@ _GL_WARN_REAL_FLOATING_DECL (isinf);
 # 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))
@@ -2347,8 +2342,8 @@ _GL_EXTERN_C int isnanf (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
@@ -2368,10 +2363,11 @@ _GL_EXTERN_C int isnand (double x);
 # 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))
@@ -2391,20 +2387,20 @@ _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
    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)
@@ -2414,12 +2410,12 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
    (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
index c74795ecd0b7c72f497be11cdcee7310ed97afab..8d1841d5aeb8828a477db00a9370fb079a67e331 100644 (file)
@@ -1,4 +1,4 @@
-# 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,
@@ -58,7 +58,7 @@ AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM],
       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
@@ -81,7 +81,7 @@ AC_DEFUN([gl_HAVE_ISNAND_NO_LIBM],
       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
index 7dd67bd8b4be1165f3a46436f1fc26e43d63f6aa..3863aa159c0c66813d14c7e2ca8d0878c8ba99aa 100644 (file)
@@ -1,4 +1,4 @@
-# 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,
@@ -74,12 +74,9 @@ AC_DEFUN([gl_HAVE_ISNANF_NO_LIBM],
       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))
@@ -102,12 +99,9 @@ AC_DEFUN([gl_HAVE_ISNANF_IN_LIBM],
       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))
@@ -133,12 +127,9 @@ AC_DEFUN([gl_ISNANF_WORKS],
       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))
index 75d5462975017df7943e0bc18551ed40e3943557..d50c53e16c92f0593fdf7563a7e97d1e8b671004 100644 (file)
@@ -1,4 +1,4 @@
-# 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,
@@ -68,12 +68,9 @@ AC_DEFUN([gl_HAVE_ISNANL_NO_LIBM],
       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))
@@ -96,12 +93,9 @@ AC_DEFUN([gl_HAVE_ISNANL_IN_LIBM],
       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))
@@ -129,12 +123,9 @@ AC_DEFUN([gl_FUNC_ISNANL_WORKS],
 #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))