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.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/list.h b/list.h
index 47ce33b..ab52acf 100644
--- a/list.h
+++ b/list.h
@@ -35,8 +35,11 @@
#define prefetch(x)
#ifndef container_of
-#define container_of(ptr, type, member) ( \
- (type *)( (char *)ptr - offsetof(type,member) ))
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *) NULL)->member) *__mptr = (ptr); \
+ (type *) ((char *) __mptr - offsetof(type, member)); \
+ })
#endif
struct list_head {