From: Andrzej Zaborowski <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5234] Move offsetof to osdep.h, remove local defintions.
Date: Tue, 16 Sep 2008 13:36:58 +0000 [thread overview]
Message-ID: <E1Kfaji-0006Qq-BI@cvs.savannah.gnu.org> (raw)
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 other threads:[~2008-09-16 13:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Kfaji-0006Qq-BI@cvs.savannah.gnu.org \
--to=balrogg@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).