aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 09:04:42 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 09:15:47 +0100
commit71f1500390d8b26e38c151b95d2c48b328df15b1 (patch)
treeb7b4e79076e05c914c2e20bd1c3ffd7185dd1721 /include
parentab4aea7b40f8977fe3d67875d0acb4032cf9d0c5 (diff)
Add container_of implementation to utilities
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/util/util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/util/util.h b/include/util/util.h
index a08c7ee..095f02a 100644
--- a/include/util/util.h
+++ b/include/util/util.h
@@ -15,6 +15,9 @@
#include "compat.h"
+#define container_of(ptr, type, member) \
+ ((type *)((char *)ptr - offsetof(type, member)))
+
#if defined(__GNUC__) || defined(__clang__)
#define UI_ADD_OV __builtin_uadd_overflow
#define UL_ADD_OV __builtin_uaddl_overflow