bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improve clang support (3)


From: Bruno Haible
Subject: improve clang support (3)
Date: Thu, 06 Aug 2020 20:37:14 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

clang supports __builtin_expect, even on Windows.

Most Gnulib modules use the 'builtin-expect' module with its Autoconf test,
however, some use the macros from lib/cdefs.h.


2020-08-06  Bruno Haible  <bruno@clisp.org>

        Use __builtin_expect with clang everywhere.
        * lib/cdefs.h (__glibc_unlikely, __glibc_likely): Use the GCC built-in
        also on clang.

diff --git a/lib/cdefs.h b/lib/cdefs.h
index 2158379..b034c0b 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -401,7 +401,7 @@
 # endif
 #endif
 
-#if __GNUC__ >= 3
+#if (__GNUC__ >= 3) || (__clang_major__ >= 4)
 # define __glibc_unlikely(cond)        __builtin_expect ((cond), 0)
 # define __glibc_likely(cond)  __builtin_expect ((cond), 1)
 #else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]