Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWGV0-0000VR-FF for qemu-devel@nongnu.org; Thu, 21 Aug 2008 16:11:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWGUz-0000Tr-Mz for qemu-devel@nongnu.org; Thu, 21 Aug 2008 16:11:13 -0400 Received: from [199.232.76.173] (port=55780 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWGUz-0000TN-Gd for qemu-devel@nongnu.org; Thu, 21 Aug 2008 16:11:13 -0400 Received: from savannah.gnu.org ([199.232.41.3]:52954 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KWGUz-0006EH-7Z for qemu-devel@nongnu.org; Thu, 21 Aug 2008 16:11:13 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KWGUy-0004Xc-6S for qemu-devel@nongnu.org; Thu, 21 Aug 2008 20:11:12 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KWGUx-0004XV-VE for qemu-devel@nongnu.org; Thu, 21 Aug 2008 20:11:12 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 21 Aug 2008 20:11:11 +0000 Subject: [Qemu-devel] [5057] add container_of() macro to osdep.h (Gerd Hoffmann) 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 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 Signed-off-by: Anthony Liguori 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