Misc: Swap LIKELY/UNLIKELY macros for attributes

This commit is contained in:
Stenzek
2023-09-05 21:17:11 +10:00
parent adc124c759
commit 60aca2fc4d
8 changed files with 13 additions and 22 deletions

View File

@ -484,7 +484,7 @@ u64 Threading::GetThreadTicksPerSecond()
// On x86, despite what the MS documentation says, this basically appears to be rdtsc.
// So, the frequency is our base clock speed (and stable regardless of power management).
static u64 frequency = 0;
if (UNLIKELY(frequency == 0))
if (frequency == 0) [[unlikely]]
{
frequency = 1000000;

View File

@ -56,15 +56,6 @@ char (&__countof_ArraySizeHelper(T (&array)[N]))[N];
#define printflike(n,m)
#endif
#ifdef _MSC_VER
// TODO: Use C++20 [[likely]] when available.
#define LIKELY(x) (!!(x))
#define UNLIKELY(x) (!!(x))
#else
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#endif
// [[noreturn]] which can be used on function pointers.
#ifdef _MSC_VER
// __declspec(noreturn) produces error C3829.