includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"

Since we require GCC version 4.8 or newer now, we can be sure that
the builtin functions are always available on GCC. And for Clang,
we can check the availablility with __has_builtin instead.

Backports commit f773b423cc61f3ca18af5337101c158a52aaae2c from qemu
This commit is contained in:
Thomas Huth 2018-12-18 03:55:39 -05:00 committed by Lioncash
parent 3ba2114043
commit c584171cf8
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7

View File

@ -210,7 +210,7 @@ static inline int cto64(uint64_t val)
*/
static inline int clrsb32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(4, 7)
#if __has_builtin(__builtin_clrsb) || !defined(__clang__)
return __builtin_clrsb(val);
#else
return clz32(val ^ ((int32_t)val >> 1)) - 1;
@ -226,7 +226,7 @@ static inline int clrsb32(uint32_t val)
*/
static inline int clrsb64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(4, 7)
#if __has_builtin(__builtin_clrsbll) || !defined(__clang__)
return __builtin_clrsbll(val);
#else
return clz64(val ^ ((int64_t)val >> 1)) - 1;