diff options
author | Kay Sievers <kay@vrfy.org> | 2012-05-07 21:06:55 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-05-08 01:57:17 +0200 |
commit | bbc98d32560cc456531bf254f7b69054921082bd (patch) | |
tree | 0c4c10fe1944119fa17a051cd69e840201ed94bc /src/shared/macro.h | |
parent | b80efeb9ae23b493d03501caa7e6334d1db65dd9 (diff) |
util: split-out hwclock.[ch]
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r-- | src/shared/macro.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h index 1355aac908..1c0aa915ad 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -57,6 +57,17 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) +/* + * 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) );}) + #ifndef MAX #define MAX(a,b) \ __extension__ ({ \ |