qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [5234] Move offsetof to osdep.h, remove local defintions.


From: Andrzej Zaborowski
Subject: [Qemu-devel] [5234] Move offsetof to osdep.h, remove local defintions.
Date: Tue, 16 Sep 2008 13:36:58 +0000

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))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]