commit 20b8cd2a8cdb37cd978e6fb4bb04bc2793789e43
parent f65a229ee91b37a5fcc56b5a929b647afd862fb6
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 14 Jul 2022 19:34:30 +0100
CMT_LIKELY and CMT_UNLIKELY
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/include/kfr/cident.h b/include/kfr/cident.h
@@ -361,6 +361,9 @@ extern char* gets(char* __s);
#define CMT_FLATTEN __attribute__((__flatten__))
#define CMT_RESTRICT __restrict__
+#define CMT_LIKELY(...) __builtin_expect(__VA_ARGS__, 1)
+#define CMT_UNLIKELY(...) __builtin_expect(__VA_ARGS__, 0)
+
#elif defined(CMT_MSVC_ATTRIBUTES)
#define CMT_ALWAYS_INLINE __forceinline
@@ -376,6 +379,9 @@ extern char* gets(char* __s);
#define CMT_FLATTEN
#define CMT_RESTRICT __restrict
+#define CMT_LIKELY(...) (__VA_ARGS__)
+#define CMT_UNLIKELY(...) (__VA_ARGS__)
+
#endif
#define CMT_INTRINSIC CMT_INLINE CMT_NODEBUG