Commit 62a6e3e19a35e19a66abe6eec66005defac06d7c
1 parent
bcfad70f
add container_of() macro to osdep.h (Gerd Hoffmann)
From linux kernel sources, xen bits will use it, put it into a place where others can see and use it too ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5057 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
4 additions
and
0 deletions
osdep.h
... | ... | @@ -23,6 +23,10 @@ |
23 | 23 | #define unlikely(x) __builtin_expect(!!(x), 0) |
24 | 24 | #endif |
25 | 25 | |
26 | +#define container_of(ptr, type, member) ({ \ | |
27 | + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | |
28 | + (type *)( (char *)__mptr - offsetof(type,member) );}) | |
29 | + | |
26 | 30 | #ifndef MIN |
27 | 31 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
28 | 32 | #endif | ... | ... |