From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWD1L-0002IF-Dx for qemu-devel@nongnu.org; Thu, 21 Aug 2008 12:28:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWD1I-0002GA-1c for qemu-devel@nongnu.org; Thu, 21 Aug 2008 12:28:21 -0400 Received: from [199.232.76.173] (port=37101 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWD1H-0002Fn-JC for qemu-devel@nongnu.org; Thu, 21 Aug 2008 12:28:19 -0400 Received: from mx1.redhat.com ([66.187.233.31]:46321) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KWD1G-0005xX-Ad for qemu-devel@nongnu.org; Thu, 21 Aug 2008 12:28:18 -0400 From: Gerd Hoffmann Date: Thu, 21 Aug 2008 18:27:24 +0200 Message-Id: <1219336054-15919-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1219336054-15919-1-git-send-email-kraxel@redhat.com> References: <1219336054-15919-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/13] add container_of() macro to osdep.h Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com Cc: 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 --- osdep.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/osdep.h b/osdep.h index 6312e7a..09ebace 100644 --- a/osdep.h +++ b/osdep.h @@ -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 -- 1.5.5.1