summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-06-30 11:47:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-06-30 11:48:45 +0200
commit2ed75f0586897405fd26215fcfe7b9d17841affc (patch)
tree257450a0d1000e8f5652f418bac207db40664ee4 /compat
parent64cf540c76acf10742d32e2aa28d73a48e459bc2 (diff)
compat: add restrict macros
Diffstat (limited to 'compat')
-rw-r--r--compat/util.hpp12
1 files changed, 10 insertions, 2 deletions
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<typename t> using ptr = std::unique_ptr<t>;
#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)
@@ -108,6 +108,14 @@ template<typename t> using qshared = QSharedPointer<t>;
#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__
# define force_inline __attribute__((always_inline, gnu_inline))