mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 16:17:47 +00:00
AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places
Doesn't use them in libc headers so that those don't have to pull in AK/Platform.h. AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is defined in clang builds as well.) Using AK_COMPILER_GCC simplifies things some. AK_COMPILER_CLANG isn't as much of a win, other than that it's consistent with AK_COMPILER_GCC.
This commit is contained in:
parent
ff4b912b7c
commit
2af028132a
35 changed files with 64 additions and 49 deletions
|
@ -11,7 +11,7 @@
|
|||
template<Unsigned IntType>
|
||||
inline constexpr int popcount(IntType value)
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#if defined(AK_COMPILER_CLANG) || defined(AK_COMPILER_GCC)
|
||||
static_assert(sizeof(IntType) <= sizeof(unsigned long long));
|
||||
if constexpr (sizeof(IntType) <= sizeof(unsigned int))
|
||||
return __builtin_popcount(value);
|
||||
|
@ -39,7 +39,7 @@ inline constexpr int popcount(IntType value)
|
|||
template<Unsigned IntType>
|
||||
inline constexpr int count_trailing_zeroes(IntType value)
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#if defined(AK_COMPILER_CLANG) || defined(AK_COMPILER_GCC)
|
||||
static_assert(sizeof(IntType) <= sizeof(unsigned long long));
|
||||
if constexpr (sizeof(IntType) <= sizeof(unsigned int))
|
||||
return __builtin_ctz(value);
|
||||
|
@ -77,7 +77,7 @@ inline constexpr int count_trailing_zeroes_safe(IntType value)
|
|||
template<Unsigned IntType>
|
||||
inline constexpr int count_leading_zeroes(IntType value)
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#if defined(AK_COMPILER_CLANG) || defined(AK_COMPILER_GCC)
|
||||
static_assert(sizeof(IntType) <= sizeof(unsigned long long));
|
||||
if constexpr (sizeof(IntType) <= sizeof(unsigned int))
|
||||
return __builtin_clz(value) - (32 - (8 * sizeof(IntType)));
|
||||
|
@ -114,7 +114,7 @@ inline constexpr int count_leading_zeroes_safe(IntType value)
|
|||
template<Integral IntType>
|
||||
inline constexpr int bit_scan_forward(IntType value)
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#if defined(AK_COMPILER_CLANG) || defined(AK_COMPILER_GCC)
|
||||
static_assert(sizeof(IntType) <= sizeof(unsigned long long));
|
||||
if constexpr (sizeof(IntType) <= sizeof(unsigned int))
|
||||
return __builtin_ffs(value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue