qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [5057] add container_of() macro to osdep.h (Gerd Hoffmann)
@ 2008-08-21 20:11 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-08-21 20:11 UTC (permalink / raw)
  To: qemu-devel

Revision: 5057
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5057
Author:   aliguori
Date:     2008-08-21 20:11:11 +0000 (Thu, 21 Aug 2008)

Log Message:
-----------
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>

Modified Paths:
--------------
    trunk/osdep.h

Modified: trunk/osdep.h
===================================================================
--- trunk/osdep.h	2008-08-21 20:08:55 UTC (rev 5056)
+++ trunk/osdep.h	2008-08-21 20:11:11 UTC (rev 5057)
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-21 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-21 20:11 [Qemu-devel] [5057] add container_of() macro to osdep.h (Gerd Hoffmann) Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).