diff --git a/qemu/hw/arm/virt.c b/qemu/hw/arm/virt.c index 485109cc..f34d3fdd 100644 --- a/qemu/hw/arm/virt.c +++ b/qemu/hw/arm/virt.c @@ -31,11 +31,12 @@ /* Unicorn Emulator Engine */ /* By Nguyen Anh Quynh, 2015 */ +#include "qemu/osdep.h" +#include "qemu-common.h" #include "hw/arm/arm.h" #include "hw/boards.h" #include "exec/address-spaces.h" - static int machvirt_init(struct uc_struct *uc, MachineState *machine) { const char *cpu_model = machine->cpu_model; diff --git a/qemu/hw/intc/apic.c b/qemu/hw/intc/apic.c index 957a66eb..2c73db02 100644 --- a/qemu/hw/intc/apic.c +++ b/qemu/hw/intc/apic.c @@ -16,6 +16,8 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ +#include "qemu/osdep.h" +#include "qemu-common.h" #include "qemu/thread.h" #include "hw/i386/apic_internal.h" #include "hw/i386/apic.h" diff --git a/qemu/include/hw/arm/arm.h b/qemu/include/hw/arm/arm.h index 48109027..eab2de1c 100644 --- a/qemu/include/hw/arm/arm.h +++ b/qemu/include/hw/arm/arm.h @@ -12,7 +12,7 @@ #define ARM_MISC_H #include "exec/memory.h" -#include "cpu.h" +#include "target-arm/cpu-qom.h" void tosa_machine_init(struct uc_struct *uc); void machvirt_machine_init(struct uc_struct *uc); // ARM64 diff --git a/qemu/include/qemu/compiler.h b/qemu/include/qemu/compiler.h index 20909ea0..afd31256 100644 --- a/qemu/include/qemu/compiler.h +++ b/qemu/include/qemu/compiler.h @@ -103,6 +103,57 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}}; #define QEMU_ALIGN(A, B) B __attribute__((aligned(A))) +#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 +#ifndef _MSC_VER +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#else +#define container_of(ptr, type, member) ((type *)((char *)(ptr) -offsetof(type,member))) +#endif +#endif + +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char QEMU_UNUSED_VAR 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/qemu/include/qemu/osdep.h b/qemu/include/qemu/osdep.h index 7b0a7ae6..280e0e5f 100644 --- a/qemu/include/qemu/osdep.h +++ b/qemu/include/qemu/osdep.h @@ -24,45 +24,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 -#ifndef _MSC_VER -#define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - offsetof(type, member));}) -#else -#define container_of(ptr, type, member) ((type *)((char *)(ptr) -offsetof(type,member))) -#endif -#endif - -/* Convert from a base type to a parent type, with compile time checking. */ -#ifdef __GNUC__ -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ - char QEMU_UNUSED_VAR 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 @@ -88,18 +49,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 - void *qemu_try_memalign(size_t alignment, size_t size); void *qemu_memalign(size_t alignment, size_t size); void *qemu_anon_ram_alloc(size_t size, uint64_t *align); diff --git a/qemu/memory.c b/qemu/memory.c index 74a4115f..024f74b0 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -15,6 +15,8 @@ /* Modified for Unicorn Engine by Nguyen Anh Quynh, 2015 */ +#include "qemu/osdep.h" +#include "qemu-common.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/ioport.h"