From dd8fe077022138d1f6aca7e6d6cceec61f56ce95 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 21 Oct 2013 11:03:17 +0800 Subject: lib: consolidate util macros in util/util.h This change groups the offsetof, container_of and ARRAY_SIZE macros in a single header file util/util.h. Signed-off-by: Jeremy Kerr --- lib/list/list.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'lib/list/list.h') diff --git a/lib/list/list.h b/lib/list/list.h index 0174b90..ad562e4 100644 --- a/lib/list/list.h +++ b/lib/list/list.h @@ -1,6 +1,8 @@ #ifndef _LIST_H #define _LIST_H +#include + struct list_item { struct list_item *prev, *next; }; @@ -9,16 +11,6 @@ struct list { struct list_item head; }; -#ifndef container_of -#define container_of(_ptr, _type, _member) ({ \ - const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \ - (_type *)( (char *)__mptr - offsetof(_type,_member) );}) -#endif - -#ifndef offsetof -#define offsetof(_type, _member) ((size_t) &((_type *)0)->_member) -#endif - #define list_for_each(_list, _pos) \ for (_pos = (_list)->head.next; _pos != ((_list)->head); _pos = _pos->next) -- cgit v1.2.1