aboutsummaryrefslogtreecommitdiff
path: root/include/apos/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/apos/utils.h')
-rw-r--r--include/apos/utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/apos/utils.h b/include/apos/utils.h
index e060c44..af0534a 100644
--- a/include/apos/utils.h
+++ b/include/apos/utils.h
@@ -31,6 +31,14 @@
#define offsetof(type, member) ((size_t) & ((type *)0)->member)
#endif
+#if __has_builtin(__builtin_expect)
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif
+
#define container_of(ptr, type, member) \
((type *)((char *)(ptr)-offsetof(type, member)))