Promote likely()/unlikely() to public header.

I have been using this in the relay to optimize some branches in inner loop
code, and I want to do that more broadly.  This is an idiom from the linux
kernel.
This commit is contained in:
Fletcher Dunn
2020-04-06 10:45:03 -07:00
parent de39e82652
commit 04de38d166
@@ -107,6 +107,24 @@ struct iovec
struct iovec;
#endif
// likely() and unlikely(). Branch hints
// This is an idiom from the linux kernel
#ifdef __GNUC__
#ifndef likely
#define likely(x) __builtin_expect (!!(x), 1)
#endif
#ifndef unlikely
#define unlikely(x) __builtin_expect (!!(x), 0)
#endif
#else
#ifndef likely
#define likely(x) (x)
#endif
#ifndef unlikely
#define unlikely(x) (x)
#endif
#endif
// Internal stuff goes in a private namespace
namespace SteamNetworkingSocketsLib {