This code should now build the x86_x64-softmmu part 2.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#ifndef _QEMU_ELF_H
|
||||
#define _QEMU_ELF_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "platform.h"
|
||||
|
||||
/* 32-bit ELF base types. */
|
||||
typedef uint32_t Elf32_Addr;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <inttypes.h>
|
||||
#include "platform.h"
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/queue.h"
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
@ -96,7 +96,7 @@ typedef struct CPUTLBEntry {
|
||||
/* padding to get a power of two size */
|
||||
uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
|
||||
(sizeof(target_ulong) * 3 +
|
||||
((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) +
|
||||
(((-(int)sizeof(target_ulong)) * 3) & (sizeof(uintptr_t) - 1)) +
|
||||
sizeof(uintptr_t))];
|
||||
} CPUTLBEntry;
|
||||
|
||||
|
@ -391,7 +391,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
haddr = addr + env->tlb_table[mmu_idx][index].addend;
|
||||
haddr = (uintptr_t)(addr + env->tlb_table[mmu_idx][index].addend);
|
||||
return (void *)haddr;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
|
||||
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
|
||||
res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx);
|
||||
} else {
|
||||
uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
|
||||
uintptr_t hostaddr = (uintptr_t)(addr + env->tlb_table[mmu_idx][page_index].addend);
|
||||
res = glue(glue(ld, USUFFIX), _raw)(hostaddr);
|
||||
}
|
||||
return res;
|
||||
@ -100,7 +100,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
|
||||
res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX),
|
||||
MMUSUFFIX)(env, addr, mmu_idx);
|
||||
} else {
|
||||
uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
|
||||
uintptr_t hostaddr = (uintptr_t)(addr + env->tlb_table[mmu_idx][page_index].addend);
|
||||
res = glue(glue(lds, SUFFIX), _raw)(hostaddr);
|
||||
}
|
||||
return res;
|
||||
@ -126,7 +126,7 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
|
||||
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
|
||||
glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, v, mmu_idx);
|
||||
} else {
|
||||
uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
|
||||
uintptr_t hostaddr = (uintptr_t)(addr + env->tlb_table[mmu_idx][page_index].addend);
|
||||
glue(glue(st, SUFFIX), _raw)(hostaddr, v);
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ static inline void tb_set_jmp_target(TranslationBlock *tb,
|
||||
int n, uintptr_t addr)
|
||||
{
|
||||
uint16_t offset = tb->tb_jmp_offset[n];
|
||||
tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr);
|
||||
tb_set_jmp_target1((uintptr_t)((char*)tb->tc_ptr + offset), addr);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -310,6 +310,9 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
extern uintptr_t tci_tb_ptr;
|
||||
# define GETRA() tci_tb_ptr
|
||||
#elif defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
# define GETRA() (uintptr_t)_ReturnAddress()
|
||||
#else
|
||||
# define GETRA() \
|
||||
((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
|
||||
|
@ -7,31 +7,31 @@
|
||||
#include <exec/helper-head.h>
|
||||
|
||||
#define DEF_HELPER_FLAGS_0(NAME, FLAGS, ret) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) },
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) },
|
||||
|
||||
#define DEF_HELPER_FLAGS_1(NAME, FLAGS, ret, t1) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) },
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) | dh_sizemask(t1, 1) },
|
||||
|
||||
#define DEF_HELPER_FLAGS_2(NAME, FLAGS, ret, t1, t2) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
| dh_sizemask(t2, 2) },
|
||||
|
||||
#define DEF_HELPER_FLAGS_3(NAME, FLAGS, ret, t1, t2, t3) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) },
|
||||
|
||||
#define DEF_HELPER_FLAGS_4(NAME, FLAGS, ret, t1, t2, t3, t4) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) },
|
||||
|
||||
#define DEF_HELPER_FLAGS_5(NAME, FLAGS, ret, t1, t2, t3, t4, t5) \
|
||||
{ .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
|
||||
.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
{ HELPER(NAME), #NAME, FLAGS, \
|
||||
dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
|
||||
| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) \
|
||||
| dh_sizemask(t5, 5) },
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* hwaddr is the type of a physical address (its size can
|
||||
be different from 'target_ulong'). */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
typedef uint64_t hwaddr;
|
||||
#define HWADDR_MAX UINT64_MAX
|
||||
|
@ -21,8 +21,7 @@
|
||||
#define DIRTY_MEMORY_MIGRATION 2
|
||||
#define DIRTY_MEMORY_NUM 3 /* num of dirty bits */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "qemu-common.h"
|
||||
#include "exec/cpu-common.h"
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
@ -243,6 +242,19 @@ struct MemoryRegionSection {
|
||||
bool readonly;
|
||||
};
|
||||
|
||||
static inline MemoryRegionSection MemoryRegionSection_make(MemoryRegion *mr, AddressSpace *address_space,
|
||||
hwaddr offset_within_region, Int128 size, hwaddr offset_within_address_space, bool readonly)
|
||||
{
|
||||
MemoryRegionSection section;
|
||||
section.mr = mr;
|
||||
section.address_space = address_space;
|
||||
section.offset_within_region = offset_within_region;
|
||||
section.size = size;
|
||||
section.offset_within_address_space = offset_within_address_space;
|
||||
section.readonly = readonly;
|
||||
return section;
|
||||
}
|
||||
|
||||
/**
|
||||
* memory_region_init: Initialize a memory region
|
||||
*
|
||||
|
@ -42,7 +42,7 @@ these four paragraphs for those parts of this code that are retained.
|
||||
#include <sunmath.h>
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "platform.h"
|
||||
#include "config-host.h"
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
@ -125,7 +125,7 @@ typedef struct {
|
||||
uint16_t high;
|
||||
} floatx80;
|
||||
#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
|
||||
#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
|
||||
#define make_floatx80_init(exp, mant) { mant, exp }
|
||||
typedef struct {
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
uint64_t high, low;
|
||||
@ -133,8 +133,13 @@ typedef struct {
|
||||
uint64_t low, high;
|
||||
#endif
|
||||
} float128;
|
||||
#define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ })
|
||||
#define make_float128_init(high_, low_) { .high = high_, .low = low_ }
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
#define make_float128(high_, low_) ((float128) { high_, low_ })
|
||||
#define make_float128_init(high_, low_) { high_, low_ }
|
||||
#else
|
||||
#define make_float128(high_, low_) ((float128) { low_, high_ })
|
||||
#define make_float128_init(high_, low_) { low_, high_ }
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Software IEC/IEEE floating-point underflow tininess-detection mode.
|
||||
|
@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#ifndef __GLIB_COMPAT_H
|
||||
#define __GLIB_COMPAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
@ -128,13 +128,13 @@ struct APICCommonState {
|
||||
hwaddr vapic_paddr; /* note: persistence via kvmvapic */
|
||||
};
|
||||
|
||||
typedef struct VAPICState {
|
||||
QEMU_PACK( typedef struct VAPICState {
|
||||
uint8_t tpr;
|
||||
uint8_t isr;
|
||||
uint8_t zero;
|
||||
uint8_t irr;
|
||||
uint8_t enabled;
|
||||
} QEMU_PACKED VAPICState;
|
||||
}) VAPICState;
|
||||
|
||||
extern bool apic_report_tpr_access;
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "qemu/compiler.h"
|
||||
#include "qapi-types.h"
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
|
||||
/**
|
||||
* A class representing internal errors within QEMU. An error has a ErrorClass
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef QBOOL_H
|
||||
#define QBOOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "qapi/qmp/qobject.h"
|
||||
|
||||
typedef struct QBool {
|
||||
|
@ -16,8 +16,7 @@
|
||||
#include "qapi/qmp/qobject.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
#include "qemu/queue.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
#define QDICT_BUCKET_MAX 512
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef QFLOAT_H
|
||||
#define QFLOAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "qapi/qmp/qobject.h"
|
||||
|
||||
typedef struct QFloat {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef QINT_H
|
||||
#define QINT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "qapi/qmp/qobject.h"
|
||||
|
||||
typedef struct QInt {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef QSTRING_H
|
||||
#define QSTRING_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "qapi/qmp/qobject.h"
|
||||
|
||||
typedef struct QString {
|
||||
|
@ -27,18 +27,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include "glib_compat.h"
|
||||
@ -195,7 +191,7 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
|
||||
rl = (uint64_t)u.l.low * (uint64_t)b;
|
||||
rh = (uint64_t)u.l.high * (uint64_t)b;
|
||||
rh += (rl >> 32);
|
||||
res.l.high = rh / c;
|
||||
res.l.high = (uint32_t)(rh / c);
|
||||
res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
|
||||
return res.ll;
|
||||
}
|
||||
@ -235,4 +231,23 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
|
||||
#define ALL_EQ(v1, v2) ((v1) == (v2))
|
||||
#endif
|
||||
|
||||
// support for calling functions before main code is executed.
|
||||
#if defined(_MSC_VER)
|
||||
#pragma section(".CRT$XCU",read)
|
||||
#define INITIALIZER2_(f,p) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" p #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define INITIALIZER(f) INITIALIZER2_(f,"")
|
||||
#else
|
||||
#define INITIALIZER(f) INITIALIZER2_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define INITIALIZER(f) \
|
||||
static void f(void) __attribute__((constructor)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -18,7 +18,12 @@
|
||||
/* For C11 atomic ops */
|
||||
|
||||
/* Compiler barrier */
|
||||
#ifdef _MSC_VER
|
||||
// TODO: fix me!!!
|
||||
#define barrier() //{ __asm volatile("" ::: "memory"); (void)0; }
|
||||
#else
|
||||
#define barrier() ({ asm volatile("" ::: "memory"); (void)0; })
|
||||
#endif
|
||||
|
||||
#ifndef __ATOMIC_RELAXED
|
||||
|
||||
@ -31,9 +36,19 @@
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#if !QEMU_GNUC_PREREQ(4, 4)
|
||||
#if defined __x86_64__
|
||||
#define smp_mb() ({ asm volatile("mfence" ::: "memory"); (void)0; })
|
||||
# ifdef _MSC_VER
|
||||
// TODO: fix me!!!
|
||||
# define smp_mb() //{ __asm volatile("mfence" ::: "memory"); (void)0; }
|
||||
# else
|
||||
# define smp_mb() ({ asm volatile("mfence" ::: "memory"); (void)0; })
|
||||
# endif
|
||||
#else
|
||||
#define smp_mb() ({ asm volatile("lock; addl $0,0(%%esp) " ::: "memory"); (void)0; })
|
||||
# ifdef _MSC_VER
|
||||
// TODO: fix me!!!
|
||||
# define smp_mb() //{ __asm volatile("lock; addl $0,0(%esp) " ::: "memory"); (void)0; }
|
||||
# else
|
||||
# define smp_mb() ({ asm volatile("lock; addl $0,0(%%esp) " ::: "memory"); (void)0; })
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -183,6 +198,19 @@
|
||||
#endif
|
||||
|
||||
/* Provide shorter names for GCC atomic builtins. */
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define atomic_fetch_inc(ptr) InterlockedIncrement64(ptr)
|
||||
#define atomic_fetch_dec(ptr) InterlockedDecrement64(ptr)
|
||||
#define atomic_fetch_add(ptr, n) InterlockedAdd64(ptr, n)
|
||||
#define atomic_fetch_sub(ptr, n) InterlockedAdd64(ptr, -n)
|
||||
#else
|
||||
#define atomic_fetch_inc(ptr) InterlockedIncrement(ptr)
|
||||
#define atomic_fetch_dec(ptr) InterlockedDecrement(ptr)
|
||||
#define atomic_fetch_add(ptr, n) InterlockedAdd(ptr, n)
|
||||
#define atomic_fetch_sub(ptr, n) InterlockedAdd(ptr, -n)
|
||||
#endif
|
||||
#else
|
||||
#define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1)
|
||||
#define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1)
|
||||
#define atomic_fetch_add __sync_fetch_and_add
|
||||
@ -190,13 +218,28 @@
|
||||
#define atomic_fetch_and __sync_fetch_and_and
|
||||
#define atomic_fetch_or __sync_fetch_and_or
|
||||
#define atomic_cmpxchg __sync_val_compare_and_swap
|
||||
#endif
|
||||
|
||||
/* And even shorter names that return void. */
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define atomic_inc(ptr) ((void) InterlockedIncrement64(ptr))
|
||||
#define atomic_dec(ptr) ((void) InterlockedDecrement64(ptr))
|
||||
#define atomic_add(ptr, n) ((void) InterlockedAdd64(ptr, n))
|
||||
#define atomic_sub(ptr, n) ((void) InterlockedAdd64(ptr, -n))
|
||||
#else
|
||||
#define atomic_inc(ptr) ((void) InterlockedIncrement(ptr))
|
||||
#define atomic_dec(ptr) ((void) InterlockedDecrement(ptr))
|
||||
#define atomic_add(ptr, n) ((void) InterlockedAdd(ptr, n))
|
||||
#define atomic_sub(ptr, n) ((void) InterlockedAdd(ptr, -n))
|
||||
#endif
|
||||
#else
|
||||
#define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
|
||||
#define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))
|
||||
#define atomic_add(ptr, n) ((void) __sync_fetch_and_add(ptr, n))
|
||||
#define atomic_sub(ptr, n) ((void) __sync_fetch_and_sub(ptr, n))
|
||||
#define atomic_and(ptr, n) ((void) __sync_fetch_and_and(ptr, n))
|
||||
#define atomic_or(ptr, n) ((void) __sync_fetch_and_or(ptr, n))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef BITOPS_H
|
||||
#define BITOPS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include "host-utils.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define BSWAP_H
|
||||
|
||||
#include "config-host.h"
|
||||
#include <inttypes.h>
|
||||
#include "platform.h"
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include "fpu/softfloat.h"
|
||||
|
@ -5,6 +5,58 @@
|
||||
|
||||
#include "config-host.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// MSVC support
|
||||
|
||||
#define inline __inline
|
||||
#define __func__ __FUNCTION__
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#define isinf(x) (!_finite(x))
|
||||
|
||||
static double rint( double x )
|
||||
{
|
||||
return floor(x < 0 ? x - 0.5 : x + 0.5);
|
||||
}
|
||||
|
||||
union MSVC_FLOAT_HACK
|
||||
{
|
||||
unsigned char Bytes[4];
|
||||
float Value;
|
||||
};
|
||||
|
||||
#ifndef NAN
|
||||
static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
|
||||
#define NAN (__NAN.Value)
|
||||
#endif
|
||||
|
||||
#define QEMU_DIV0 __pragma(warning(suppress:2124)) // divide by zero error
|
||||
|
||||
#define QEMU_GNUC_PREREQ(maj, min) 0
|
||||
|
||||
#define QEMU_NORETURN __declspec(noreturn)
|
||||
#define QEMU_UNUSED_VAR __pragma(warning(suppress:4100)) // unused variables only
|
||||
#define QEMU_UNUSED_FUNC
|
||||
#define QEMU_WARN_UNUSED_RESULT
|
||||
#define QEMU_ARTIFICIAL
|
||||
#define QEMU_PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
|
||||
|
||||
#define QEMU_ALIGN(A, B) __declspec(align(A)) B
|
||||
|
||||
#define cat(x,y) x ## y
|
||||
#define cat2(x,y) cat(x,y)
|
||||
#define QEMU_BUILD_BUG_ON(x) \
|
||||
typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] QEMU_UNUSED_VAR;
|
||||
|
||||
#define GCC_FMT_ATTR(n, m)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef NAN
|
||||
#define NAN (0.0 / 0.0)
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
|
||||
| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
|
||||
@ -18,6 +70,9 @@
|
||||
|
||||
#define QEMU_NORETURN __attribute__ ((__noreturn__))
|
||||
|
||||
#define QEMU_UNUSED_VAR __attribute__((unused))
|
||||
#define QEMU_UNUSED_FUNC __attribute__((unused))
|
||||
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
@ -31,11 +86,13 @@
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define QEMU_PACKED __attribute__((gcc_struct, packed))
|
||||
# define QEMU_PACK( __Declaration__ ) __Declaration__ __attribute__((gcc_struct, packed))
|
||||
#else
|
||||
# define QEMU_PACKED __attribute__((packed))
|
||||
# define QEMU_PACK( __Declaration__ ) __Declaration__ __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#define QEMU_ALIGN(A, B) B __attribute__((aligned(A)))
|
||||
|
||||
#define cat(x,y) x ## y
|
||||
#define cat2(x,y) cat(x,y)
|
||||
#define QEMU_BUILD_BUG_ON(x) \
|
||||
@ -58,4 +115,6 @@
|
||||
#define GCC_FMT_ATTR(n, m)
|
||||
#endif
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif /* COMPILER_H */
|
||||
|
@ -150,7 +150,7 @@ static inline int clz64(uint64_t val)
|
||||
val >>= 32;
|
||||
}
|
||||
|
||||
return cnt + clz32(val);
|
||||
return cnt + clz32((uint32_t)val);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ static inline int ctz64(uint64_t val)
|
||||
val >>= 32;
|
||||
}
|
||||
|
||||
return cnt + ctz32(val);
|
||||
return cnt + ctz32((uint32_t)val);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ static inline int ctpop64(uint64_t val)
|
||||
val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL);
|
||||
val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL);
|
||||
|
||||
return val;
|
||||
return (int)val;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -379,4 +379,13 @@ static inline int ctpop64(uint64_t val)
|
||||
# error Unknown sizeof long
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
#if defined(_WIN64)
|
||||
#define isnan _isnanf
|
||||
#else
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -2,8 +2,7 @@
|
||||
#define INT128_H
|
||||
|
||||
//#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
|
||||
typedef struct Int128 Int128;
|
||||
|
||||
@ -14,7 +13,8 @@ struct Int128 {
|
||||
|
||||
static inline Int128 int128_make64(uint64_t a)
|
||||
{
|
||||
return (Int128) { a, 0 };
|
||||
Int128 i128 = { a, 0 };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline uint64_t int128_get64(Int128 a)
|
||||
@ -35,17 +35,20 @@ static inline Int128 int128_one(void)
|
||||
|
||||
static inline Int128 int128_2_64(void)
|
||||
{
|
||||
return (Int128) { 0, 1 };
|
||||
Int128 i128 = { 0, 1 };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline Int128 int128_exts64(int64_t a)
|
||||
{
|
||||
return (Int128) { .lo = a, .hi = (a < 0) ? -1 : 0 };
|
||||
Int128 i128 = { a, (a < 0) ? -1 : 0 };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline Int128 int128_and(Int128 a, Int128 b)
|
||||
{
|
||||
return (Int128) { a.lo & b.lo, a.hi & b.hi };
|
||||
Int128 i128 = { a.lo & b.lo, a.hi & b.hi };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline Int128 int128_rshift(Int128 a, int n)
|
||||
@ -56,9 +59,11 @@ static inline Int128 int128_rshift(Int128 a, int n)
|
||||
}
|
||||
h = a.hi >> (n & 63);
|
||||
if (n >= 64) {
|
||||
return (Int128) { h, h >> 63 };
|
||||
Int128 i128 = { h, h >> 63 };
|
||||
return i128;
|
||||
} else {
|
||||
return (Int128) { (a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h };
|
||||
Int128 i128 = { (a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h };
|
||||
return i128;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,18 +77,21 @@ static inline Int128 int128_add(Int128 a, Int128 b)
|
||||
*
|
||||
* So the carry is lo < a.lo.
|
||||
*/
|
||||
return (Int128) { lo, (uint64_t)a.hi + b.hi + (lo < a.lo) };
|
||||
Int128 i128 = { lo, (uint64_t)a.hi + b.hi + (lo < a.lo) };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline Int128 int128_neg(Int128 a)
|
||||
{
|
||||
uint64_t lo = -a.lo;
|
||||
return (Int128) { lo, ~(uint64_t)a.hi + !lo };
|
||||
uint64_t lo = 0-a.lo;
|
||||
Int128 i128 = { lo, ~(uint64_t)a.hi + !lo };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline Int128 int128_sub(Int128 a, Int128 b)
|
||||
{
|
||||
return (Int128){ a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo) };
|
||||
Int128 i128 = { a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo) };
|
||||
return i128;
|
||||
}
|
||||
|
||||
static inline bool int128_nonneg(Int128 a)
|
||||
|
@ -2,8 +2,7 @@
|
||||
#define QEMU_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "platform.h"
|
||||
#include "qemu/compiler.h"
|
||||
#include "qom/cpu.h"
|
||||
|
||||
|
@ -26,15 +26,17 @@ void DSO_STAMP_FUN(void);
|
||||
* check fails during module loading */
|
||||
void qemu_module_dummy(void);
|
||||
|
||||
//static void __attribute__((constructor)) do_qemu_init_ ## function(void)
|
||||
//static void __attribute__((constructor)) do_qemu_init_ ## function(void)
|
||||
#define module_init(function, type) \
|
||||
static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
|
||||
INITIALIZER(do_qemu_init_ ## function) \
|
||||
{ \
|
||||
register_dso_module_init(function, type); \
|
||||
}
|
||||
#else
|
||||
/* This should not be used directly. Use block_init etc. instead. */
|
||||
#define module_init(function, type) \
|
||||
static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
|
||||
INITIALIZER(do_qemu_init_ ## function) \
|
||||
{ \
|
||||
register_module_init(function, type); \
|
||||
}
|
||||
|
@ -4,8 +4,7 @@
|
||||
#include "config-host.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include <sys/types.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <sys/signal.h>
|
||||
@ -18,7 +17,7 @@
|
||||
#define WEXITSTATUS(x) (x)
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "platform.h"
|
||||
|
||||
#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
|
||||
/* [u]int_fast*_t not in <sys/int_types.h> */
|
||||
@ -44,15 +43,19 @@ typedef signed int int_fast16_t;
|
||||
#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 __attribute__((unused)) offset_must_be_zero[ \
|
||||
char QEMU_UNUSED_VAR offset_must_be_zero[ \
|
||||
-offsetof(type, field)]; \
|
||||
container_of(dev, type, field);}))
|
||||
#else
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef QEMU_RANGE_H
|
||||
#define QEMU_RANGE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "platform.h"
|
||||
#include <qemu/typedefs.h>
|
||||
#include "qemu/queue.h"
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#ifndef __QEMU_THREAD_H
|
||||
#define __QEMU_THREAD_H 1
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
|
||||
typedef struct QemuMutex QemuMutex;
|
||||
typedef struct QemuThread QemuThread;
|
||||
|
@ -493,7 +493,7 @@ static inline int64_t get_clock(void)
|
||||
{
|
||||
LARGE_INTEGER ti;
|
||||
QueryPerformanceCounter(&ti);
|
||||
return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq);
|
||||
return muldiv64(ti.QuadPart, (uint32_t)get_ticks_per_sec(), (uint32_t)clock_freq);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -545,9 +545,13 @@ static inline int64_t cpu_get_real_ticks(void)
|
||||
|
||||
static inline int64_t cpu_get_real_ticks(void)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return __rdtsc();
|
||||
#else
|
||||
int64_t val;
|
||||
asm volatile ("rdtsc" : "=A" (val));
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
@ -532,7 +532,7 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu->uc, cpu);
|
||||
|
||||
return cc->do_unaligned_access(cpu, addr, is_write, is_user, retaddr);
|
||||
cc->do_unaligned_access(cpu, addr, is_write, is_user, retaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -15,8 +15,7 @@
|
||||
#define QEMU_OBJECT_H
|
||||
|
||||
#include "glib_compat.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#ifndef QEMU_OS_WIN32_H
|
||||
#define QEMU_OS_WIN32_H
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
|
Reference in New Issue
Block a user