From 2ed75f0586897405fd26215fcfe7b9d17841affc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Jun 2017 11:47:49 +0200 Subject: compat: add restrict macros --- compat/util.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'compat') diff --git a/compat/util.hpp b/compat/util.hpp index 4ad01544..88bff96c 100644 --- a/compat/util.hpp +++ b/compat/util.hpp @@ -46,8 +46,8 @@ template using ptr = std::unique_ptr; #endif #if defined __GNUC__ -# define likely(x) __builtin_expect((x),1) -# define unlikely(x) __builtin_expect((x),0) +# define likely(x) __builtin_expect(!!(x),1) +# define unlikely(x) __builtin_expect(!!(x),0) #else # define likely(x) (x) # define unlikely(x) (x) @@ -107,6 +107,14 @@ template using qshared = QSharedPointer; # define restrict #endif +#if defined _MSC_VER +# define restrict_ref restrict +#elif defined __GNUG__ +# define restrict_ref restrict +#else +# define restrict_ref +#endif + #if defined _MSC_VER # define force_inline __forceinline #elif defined __GNUG__ -- cgit v1.2.3