[5234] Move offsetof to osdep.h, remove local defintions.
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
===================================================================
block-qcow2.c +0 -4
@@ -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
===================================================================
exec-all.h +0 -4
@@ -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
===================================================================
linux-user/signal.c +0 -4
@@ -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
===================================================================
monitor.c +0 -4
@@ -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
===================================================================
osdep.h +7 -2
@@ -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))