diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2204760615d8..9fe11d9b6dc4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -150,6 +150,19 @@ extern const char *print_tainted(void); #define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __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) );}) + #endif /* __KERNEL__ */ #define SI_LOAD_SHIFT 16 |
