add a base64 implementation (based on FreeBSD code)
[project/libubox.git] / list.h
diff --git a/list.h b/list.h
index 8425aff..ab52acf 100644 (file)
--- a/list.h
+++ b/list.h
 #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 {
@@ -45,6 +48,7 @@ struct list_head {
 };
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
+#undef LIST_HEAD
 #define LIST_HEAD(name)        struct list_head name = LIST_HEAD_INIT(name)
 
 static inline void