aboutsummaryrefslogtreecommitdiff
path: root/include/apos/utils.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-04-16 20:27:46 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-04-16 20:27:46 +0300
commit67c9dc06ca0b5aec6430d50af9444bbe85b6deb5 (patch)
treed8f1d9b0b401f61312634b8e2d579249ea4dec34 /include/apos/utils.h
parente71dd2d9fe1cc3a6d074f9c1894e2c5200cecdb1 (diff)
downloadkmi-67c9dc06ca0b5aec6430d50af9444bbe85b6deb5.tar.gz
kmi-67c9dc06ca0b5aec6430d50af9444bbe85b6deb5.zip
initial thread id handling
+ At least initial in the sense that this seems like the smartest way to handle things, that is.
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)))