]> git.proxmox.com Git - qemu.git/commitdiff
Move offsetof to osdep.h, remove local defintions.
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 16 Sep 2008 13:36:57 +0000 (13:36 +0000)
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 16 Sep 2008 13:36:57 +0000 (13:36 +0000)
With this container_of can actually be used without causing build errors.
Reformat container_of.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5234 c046a42c-6fe2-441c-8c8c-71466251a162

block-qcow2.c
exec-all.h
linux-user/signal.c
monitor.c
osdep.h

index b9f168866378bb41618572bfea362c7446b4bef6..5f0fbe8f9e8e4e5fd0fb3aadbb1b43e768b3b49f 100644 (file)
 
 #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;
index c5009dc62cecb243c55d0b0e9178a2cb3d745479..84944c585edaf21a0fe28a4f21ee13a52eb96ac4 100644 (file)
@@ -256,10 +256,6 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
 
 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"
index 8fb3469ccab2463667ac887fb50bdd11dd5666c0..96409233c86806ceddd32469ef7984b2edaf91ad 100644 (file)
@@ -549,10 +549,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,
     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)
 {
index 43b188a7f66a441800d40362314a1bb79973311f..8ac5db97bfefaa1a2b4e0c5ec8d55954cb641c4d 100644 (file)
--- a/monitor.c
+++ b/monitor.c
 //#define DEBUG
 //#define DEBUG_COMPLETION
 
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
 /*
  * Supported types:
  *
diff --git a/osdep.h b/osdep.h
index 09ebace5b3f7c722f2064c6a9ca6362ac3581464..9e8547cea41667e59069334902fe5e1522ba1afc 100644 (file)
--- a/osdep.h
+++ b/osdep.h
 #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))