diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-11-25 18:49:03 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 09:41:29 -0600 |
commit | 5096fae3fdabc889545ecae508e3dbd0579fcbc9 (patch) | |
tree | ce109252b3dfda5add1b80e8ea6bc5f3aec7d57d /osdep.h | |
parent | 45460d1a53d202550945e2b144af8ebb1d62bed0 (diff) |
qdev: move DO_UPCAST() into osdep.h
Nothing qdev specific about this, make it available throughtout.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'osdep.h')
-rw-r--r-- | osdep.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -37,6 +37,16 @@ (type *) ((char *) __mptr - offsetof(type, member));}) #endif +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char __attribute__((unused)) offset_must_be_zero[ \ + -offsetof(type, field)]; \ + container_of(dev, type, field);})) +#else +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) +#endif + #define typeof_field(type, field) typeof(((type *)0)->field) #define type_check(t1,t2) ((t1*)0 - (t2*)0) |