summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/kernel/container_of.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/kernel/container_of.h b/include/kernel/container_of.h
new file mode 100644
index 0000000..1b5b444
--- /dev/null
+++ b/include/kernel/container_of.h
@@ -0,0 +1,10 @@
+#ifndef KERNEL_CONTAINER_OF_H
+#define KERNEL_CONTAINER_OF_H
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({ \
+ const typeof(((type*)0)->member)*__mptr = (ptr); \
+ (type*)((char*)__mptr - offsetof(type, member)); })
+#endif
+
+#endif