Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'list.h')
-rw-r--r--list.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/list.h b/list.h
index a2cb241..6aa7b2a 100644
--- a/list.h
+++ b/list.h
@@ -42,6 +42,14 @@
})
#endif
+#ifndef container_of_safe
+#define container_of_safe(ptr, type, member) \
+ ({ \
+ const __typeof__(((type *) NULL)->member) *__mptr = (ptr); \
+ __mptr ? (type *)((char *) __mptr - offsetof(type, member)) : NULL; \
+ })
+#endif
+
struct list_head {
struct list_head *next;
struct list_head *prev;