X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fcommon.h;h=26e1b469a12e048da358580131c52e7d110ad83f;hb=b77cddc7b52acd4ed78830ac681a398dd3053938;hp=d0f57040ee435c627457711d264fa34682a0816e;hpb=42fd5f87b1613d3039f57e93c16f760a768d3e84;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/common.h b/include/common.h index d0f5704..26e1b46 100644 --- a/include/common.h +++ b/include/common.h @@ -176,6 +176,17 @@ typedef void (interrupt_handler_t)(void *); (__x > __y) ? __x : __y; }) +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + /* * Function Prototypes */