aboutsummaryrefslogtreecommitdiffstats
path: root/osdep.h
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-05-10 18:48:35 -0700
committerDavid 'Digit' Turner <digit@android.com>2010-05-11 17:10:19 -0700
commit2910f183ddd5286911bc1e3499ea93cb57de8b75 (patch)
tree43cfd4b9a6697496732722ff7f2fb66d5782597c /osdep.h
parent0119362f0d74ca74f3ea743f6e0e527a9edcc474 (diff)
downloadexternal_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.zip
external_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.tar.gz
external_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.tar.bz2
Upstream: Misc integration - includes qobject.h and related sources
Change-Id: Idfa93ab5c67c95a3bc1869eeaf3a84a75fe24cd6
Diffstat (limited to 'osdep.h')
-rw-r--r--osdep.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/osdep.h b/osdep.h
index ffbf221..0252217 100644
--- a/osdep.h
+++ b/osdep.h
@@ -2,6 +2,7 @@
#define QEMU_OSDEP_H
#include <stdarg.h>
+#include <stddef.h>
#ifdef __OpenBSD__
#include <sys/types.h>
#include <sys/signal.h>
@@ -36,6 +37,19 @@
(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
@@ -48,12 +62,9 @@
#endif
#ifndef always_inline
-#if (__GNUC__ < 3) || defined(__APPLE__)
-#define always_inline inline
-#else
-#define always_inline __attribute__ (( always_inline )) __inline__
+#if !((__GNUC__ < 3) || defined(__APPLE__))
#ifdef __OPTIMIZE__
-#define inline always_inline
+#define inline __attribute__ (( always_inline )) __inline__
#endif
#endif
#else