qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org
Subject: [Qemu-devel] [PATCH 03/12] osdep.h: Move some compiler-specific things to compiler.h
Date: Wed, 22 Jul 2015 17:44:02 +0100	[thread overview]
Message-ID: <1437583451-9677-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1437583451-9677-1-git-send-email-peter.maydell@linaro.org>

osdep.h has a few things which are really compiler specific;
move them to compiler.h, and include compiler.h from osdep.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/compiler.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/qemu/osdep.h    | 48 +-----------------------------------------------
 2 files changed, 48 insertions(+), 47 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index df9dd51..bdc9a60 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -42,6 +42,53 @@
 # define QEMU_PACKED __attribute__((packed))
 #endif
 
+#ifndef glue
+#define xglue(x, y) x ## y
+#define glue(x, y) xglue(x, y)
+#define stringify(s)	tostring(s)
+#define tostring(s)	#s
+#endif
+
+#ifndef likely
+#if __GNUC__ < 3
+#define __builtin_expect(x, n) (x)
+#endif
+
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x)   __builtin_expect(!!(x), 0)
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({                      \
+        const typeof(((type *) 0)->member) *__mptr = (ptr);     \
+        (type *) ((char *) __mptr - offsetof(type, member));})
+#endif
+
+/* Convert from a base type to a parent type, with compile time checking.  */
+#ifdef __GNUC__
+#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
+    char __attribute__((unused)) offset_must_be_zero[ \
+        -offsetof(type, field)]; \
+    container_of(dev, type, field);}))
+#else
+#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
+#endif
+
+#define typeof_field(type, field) typeof(((type *)0)->field)
+#define type_check(t1,t2) ((t1*)0 - (t2*)0)
+
+#ifndef always_inline
+#if !((__GNUC__ < 3) || defined(__APPLE__))
+#ifdef __OPTIMIZE__
+#undef inline
+#define inline __attribute__ (( always_inline )) __inline__
+#endif
+#endif
+#else
+#undef inline
+#define inline always_inline
+#endif
+
 #define cat(x,y) x ## y
 #define cat2(x,y) cat(x,y)
 #define QEMU_BUILD_BUG_ON(x) \
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e9b8b92..4ae2c64 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -2,6 +2,7 @@
 #define QEMU_OSDEP_H
 
 #include "config-host.h"
+#include "qemu/compiler.h"
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdbool.h>
@@ -27,41 +28,6 @@ typedef unsigned int            uint_fast16_t;
 typedef signed int              int_fast16_t;
 #endif
 
-#ifndef glue
-#define xglue(x, y) x ## y
-#define glue(x, y) xglue(x, y)
-#define stringify(s)	tostring(s)
-#define tostring(s)	#s
-#endif
-
-#ifndef likely
-#if __GNUC__ < 3
-#define __builtin_expect(x, n) (x)
-#endif
-
-#define likely(x)   __builtin_expect(!!(x), 1)
-#define unlikely(x)   __builtin_expect(!!(x), 0)
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) ({                      \
-        const typeof(((type *) 0)->member) *__mptr = (ptr);     \
-        (type *) ((char *) __mptr - offsetof(type, member));})
-#endif
-
-/* Convert from a base type to a parent type, with compile time checking.  */
-#ifdef __GNUC__
-#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
-    char __attribute__((unused)) offset_must_be_zero[ \
-        -offsetof(type, field)]; \
-    container_of(dev, type, field);}))
-#else
-#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
-#endif
-
-#define typeof_field(type, field) typeof(((type *)0)->field)
-#define type_check(t1,t2) ((t1*)0 - (t2*)0)
-
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif
@@ -87,18 +53,6 @@ typedef signed int              int_fast16_t;
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif
 
-#ifndef always_inline
-#if !((__GNUC__ < 3) || defined(__APPLE__))
-#ifdef __OPTIMIZE__
-#undef inline
-#define inline __attribute__ (( always_inline )) __inline__
-#endif
-#endif
-#else
-#undef inline
-#define inline always_inline
-#endif
-
 int qemu_daemon(int nochdir, int noclose);
 void *qemu_try_memalign(size_t alignment, size_t size);
 void *qemu_memalign(size_t alignment, size_t size);
-- 
1.9.1

  parent reply	other threads:[~2015-07-22 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 16:43 [Qemu-devel] [PATCH 00/12] qemu-common.h/osdep.h refactoring Peter Maydell
2015-07-22 16:44 ` [Qemu-devel] [PATCH 01/12] qapi/qmp-event.c: Don't manually include os-win32.h/os-posix.h Peter Maydell
2015-07-31 12:46   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 02/12] osdep.h: Remove qemu_printf Peter Maydell
2015-07-31 12:46   ` Daniel P. Berrange
2015-07-22 16:44 ` Peter Maydell [this message]
2015-07-31 12:47   ` [Qemu-devel] [PATCH 03/12] osdep.h: Move some compiler-specific things to compiler.h Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 04/12] compiler.h: Use glue() in QEMU_BUILD_BUG_ON define Peter Maydell
2015-07-31 12:48   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 05/12] qemu-common.h: Move Win32 fixups into os-win32.h Peter Maydell
2015-07-31 12:49   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 06/12] osdep.h: Move some OS header includes and fixups from qemu-common.h Peter Maydell
2015-07-31 12:50   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 07/12] osdep.h: Add header comment Peter Maydell
2015-07-31 17:31   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 08/12] qemu-common.h: Move muldiv64() to host-utils.h Peter Maydell
2015-07-31 17:32   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 09/12] apic_internal.h: Include cpu.h directly Peter Maydell
2015-07-31 17:33   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 10/12] timer.h: Don't include qemu-common.h Peter Maydell
2015-07-31 17:36   ` Daniel P. Berrange
2015-07-22 16:44 ` [Qemu-devel] [PATCH 11/12] event_notifier.h: " Peter Maydell
2015-07-22 16:44 ` [Qemu-devel] [PATCH 12/12] throttle.h: " Peter Maydell
2015-07-22 20:09 ` [Qemu-devel] [PATCH 00/12] qemu-common.h/osdep.h refactoring Paolo Bonzini
2015-07-23 15:44 ` Markus Armbruster
2015-07-31 12:54 ` Daniel P. Berrange
2015-07-31 12:57   ` Peter Maydell
2015-07-31 17:30     ` Daniel P. Berrange
2015-08-13 17:37 ` Peter Maydell
2015-08-19 18:18   ` Peter Maydell

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=1437583451-9677-4-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=patches@linaro.org \
    --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).