From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kfajk-0000Mm-Q0 for qemu-devel@nongnu.org; Tue, 16 Sep 2008 09:37:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kfajk-0000MI-2s for qemu-devel@nongnu.org; Tue, 16 Sep 2008 09:37:00 -0400 Received: from [199.232.76.173] (port=48989 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kfajj-0000MD-Qe for qemu-devel@nongnu.org; Tue, 16 Sep 2008 09:36:59 -0400 Received: from savannah.gnu.org ([199.232.41.3]:54296 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 1Kfajj-0001lX-IQ for qemu-devel@nongnu.org; Tue, 16 Sep 2008 09:36:59 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Kfaji-0006Qv-Mc for qemu-devel@nongnu.org; Tue, 16 Sep 2008 13:36:58 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Kfaji-0006Qq-BI for qemu-devel@nongnu.org; Tue, 16 Sep 2008 13:36:58 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Tue, 16 Sep 2008 13:36:58 +0000 Subject: [Qemu-devel] [5234] Move offsetof to osdep.h, remove local defintions. 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: 5234 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5234 Author: balrog Date: 2008-09-16 13:36:57 +0000 (Tue, 16 Sep 2008) Log Message: ----------- Move offsetof to osdep.h, remove local defintions. With this container_of can actually be used without causing build errors. Reformat container_of. Modified Paths: -------------- trunk/block-qcow2.c trunk/exec-all.h trunk/linux-user/signal.c trunk/monitor.c trunk/osdep.h Modified: trunk/block-qcow2.c =================================================================== --- trunk/block-qcow2.c 2008-09-16 13:21:58 UTC (rev 5233) +++ trunk/block-qcow2.c 2008-09-16 13:36:57 UTC (rev 5234) @@ -61,10 +61,6 @@ #define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */ -#ifndef offsetof -#define offsetof(type, field) ((size_t) &((type *)0)->field) -#endif - typedef struct QCowHeader { uint32_t magic; uint32_t version; Modified: trunk/exec-all.h =================================================================== --- trunk/exec-all.h 2008-09-16 13:21:58 UTC (rev 5233) +++ trunk/exec-all.h 2008-09-16 13:36:57 UTC (rev 5234) @@ -256,10 +256,6 @@ TranslationBlock *tb_find_pc(unsigned long pc_ptr); -#ifndef offsetof -#define offsetof(type, field) ((size_t) &((type *)0)->field) -#endif - #if defined(_WIN32) #define ASM_DATA_SECTION ".section \".data\"\n" #define ASM_PREVIOUS_SECTION ".section .text\n" Modified: trunk/linux-user/signal.c =================================================================== --- trunk/linux-user/signal.c 2008-09-16 13:21:58 UTC (rev 5233) +++ trunk/linux-user/signal.c 2008-09-16 13:36:57 UTC (rev 5234) @@ -549,10 +549,6 @@ return ret; } -#ifndef offsetof -#define offsetof(type, field) ((size_t) &((type *)0)->field) -#endif - static inline int copy_siginfo_to_user(target_siginfo_t *tinfo, const target_siginfo_t *info) { Modified: trunk/monitor.c =================================================================== --- trunk/monitor.c 2008-09-16 13:21:58 UTC (rev 5233) +++ trunk/monitor.c 2008-09-16 13:36:57 UTC (rev 5234) @@ -40,10 +40,6 @@ //#define DEBUG //#define DEBUG_COMPLETION -#ifndef offsetof -#define offsetof(type, field) ((size_t) &((type *)0)->field) -#endif - /* * Supported types: * Modified: trunk/osdep.h =================================================================== --- trunk/osdep.h 2008-09-16 13:21:58 UTC (rev 5233) +++ trunk/osdep.h 2008-09-16 13:36:57 UTC (rev 5234) @@ -23,9 +23,14 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) +#endif +#ifndef container_of #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b))