summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--block-qcow2.c4
-rw-r--r--exec-all.h4
-rw-r--r--linux-user/signal.c4
-rw-r--r--monitor.c4
-rw-r--r--osdep.h9
5 files changed, 7 insertions, 18 deletions
diff --git a/block-qcow2.c b/block-qcow2.c
index b9f1688663..5f0fbe8f9e 100644
--- a/block-qcow2.c
+++ b/block-qcow2.c
@@ -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;
diff --git a/exec-all.h b/exec-all.h
index c5009dc62c..84944c585e 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -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"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 8fb3469cca..96409233c8 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -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)
 {
diff --git a/monitor.c b/monitor.c
index 43b188a7f6..8ac5db97bf 100644
--- a/monitor.c
+++ b/monitor.c
@@ -40,10 +40,6 @@
 //#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 09ebace5b3..9e8547cea4 100644
--- a/osdep.h
+++ b/osdep.h
@@ -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))