X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=list.h;h=ab52acff2f82ffbe41592144f5f193b161090521;hp=8425aff9da71e1efff2eac72642937fcbd6a03a2;hb=0c2fbbca80a242280e5bb8b079184479c9abfa6f;hpb=92da3a9bcc4934c04766e6e60aff254c04e92e97 diff --git a/list.h b/list.h index 8425aff..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 { @@ -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