]> Git Repo - qemu.git/commitdiff
add container_of() macro to osdep.h (Gerd Hoffmann)
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 21 Aug 2008 20:11:11 +0000 (20:11 +0000)
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 21 Aug 2008 20:11:11 +0000 (20:11 +0000)
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 <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5057 c046a42c-6fe2-441c-8c8c-71466251a162

osdep.h

diff --git a/osdep.h b/osdep.h
index 6312e7a2e4fa02dd03586501452fed8b02f7e3af..09ebace5b3f7c722f2064c6a9ca6362ac3581464 100644 (file)
--- a/osdep.h
+++ b/osdep.h
 #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
This page took 0.025373 seconds and 4 git commands to generate.