0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd: Fix missing __has_builtin; minor cleanup.

This commit is contained in:
Jason Volk 2022-10-09 00:09:28 +00:00
parent df522ef8e9
commit 1f57c224c6

View file

@ -31,24 +31,32 @@
// Common branch prediction macros
//
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#if !defined(likely)
#if __has_builtin(__builtin_expect)
#define likely(x) __builtin_expect(!!(x), 1)
#else
#define likely(x) (x)
#endif
#endif
#ifndef unlikely
#define unlikely(x) __builtin_expect(!!(x), 0)
#if !defined(unlikely)
#if __has_builtin(__builtin_expect)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define unlikely(x) (x)
#endif
#endif
//
// Assume
//
#ifndef assume
#if __has_builtin(__builtin_assume)
#define assume(x) assert(x); __builtin_assume(x);
#else
#define assume(x) assert(x);
#endif
#if !defined(assume)
#if __has_builtin(__builtin_assume)
#define assume(x) assert(x); __builtin_assume(x);
#else
#define assume(x) assert(x);
#endif
#endif
//
@ -77,8 +85,8 @@ namespace ircd
#if defined(__cplusplus)
namespace ircd
{
using longlong = long long;
using ulonglong = unsigned long long;
using longlong = long long;
using ulonglong = unsigned long long;
}
#endif