aboutsummaryrefslogtreecommitdiffstats
path: root/include/rin
diff options
context:
space:
mode:
Diffstat (limited to 'include/rin')
-rw-r--r--include/rin/definitions.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/rin/definitions.h b/include/rin/definitions.h
index 8364f42..b5f5667 100644
--- a/include/rin/definitions.h
+++ b/include/rin/definitions.h
@@ -21,12 +21,29 @@
#ifndef LIBRIN_DEFINITIONS_INCLUDED
#define LIBRIN_DEFINITIONS_INCLUDED
+/* gcc */
#ifdef __GNUC__
+
+/* weak symbols */
# define WEAK_SYM __attribute__((weak))
+/* optimizing likely / unlikely branches */
+# define likely(a) (__builtin_expect(!!(a), 1))
+# define unlikely(a) (__builtin_expect((a), 0))
+
+/* MSVC */
#elif defined(_MSC_VER)
+
+/* weak symbols */
# define WEAK_SYM __declspec(selectany)
+/* optimizing likely / unlikely branches */
+# define likely(a) (a)
+# define unlikely(a) (a)
+
+/* the rest – NOOP */
#else
# define WEAK_SYM
+# define likely(a) (a)
+# define unlikely(a) (a)
#endif
#define rin_once(func) \