2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-25 19:30:08 +01:00

common: add unlikely()/likely() macros

This commit is contained in:
Alibek Omarov 2022-06-29 02:36:39 +03:00
parent af8febabd1
commit b9b8b0521b

View File

@ -87,6 +87,16 @@ typedef uint64_t longtime_t;
#define NORETURN
#endif
#if defined(__has_builtin)
#if __has_builtin(__builtin_expect)
#define unlikely(x) __builtin_expect(x, 0)
#define likely(x) __builtin_expect(x, 1)
#else // __has_builtin(__builtin_expect)
#define unlikely(x) (x)
#define likely(x) (x)
#endif // __has_builtin(__builtin_expect)
#endif // defined(__has_builtin)
#ifdef XASH_BIG_ENDIAN
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))