diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-08-21 20:11:11 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-08-21 20:11:11 +0000 |
commit | 62a6e3e19a35e19a66abe6eec66005defac06d7c (patch) | |
tree | bd76194f73da039757d66fbd9e9c3561d9b3d097 /osdep.h | |
parent | bcfad70fb0189ba4aca8661e46de95e7149009c6 (diff) | |
download | qemu-62a6e3e19a35e19a66abe6eec66005defac06d7c.zip qemu-62a6e3e19a35e19a66abe6eec66005defac06d7c.tar.gz qemu-62a6e3e19a35e19a66abe6eec66005defac06d7c.tar.bz2 |
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
Diffstat (limited to 'osdep.h')
-rw-r--r-- | osdep.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -23,6 +23,10 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif |