Unicorn interface working with test app in 32bit and 64bit builds.

This commit is contained in:
xorstream
2017-01-20 17:27:22 +11:00
parent 1aeaf5c40d
commit 002151874a
17 changed files with 248 additions and 829 deletions

View File

@ -94,10 +94,14 @@ typedef struct CPUTLBEntry {
use the corresponding iotlb value. */
uintptr_t addend;
/* padding to get a power of two size */
uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
#if defined(_MSC_VER) && defined(_WIN64)
// dummy would be size 0 which isnt supported by msvc, so we remove it
#else
uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
(sizeof(target_ulong) * 3 +
(((-(int)sizeof(target_ulong)) * 3) & (sizeof(uintptr_t) - 1)) +
sizeof(uintptr_t))];
#endif
} CPUTLBEntry;
QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));

View File

@ -199,18 +199,13 @@
/* 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
// these return the new value (so we make it return the previous value)
#define atomic_fetch_inc(ptr) ((InterlockedIncrement(ptr))-1)
#define atomic_fetch_dec(ptr) ((InterlockedDecrement(ptr))+1)
#define atomic_fetch_add(ptr, n) ((InterlockedAdd(ptr, n))-n)
#define atomic_fetch_sub(ptr, n) ((InterlockedAdd(ptr, -n))+n)
#else
// these return the previous value
#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
@ -222,17 +217,10 @@
/* 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))

View File

@ -558,6 +558,9 @@ static inline int64_t cpu_get_real_ticks(void)
static inline int64_t cpu_get_real_ticks(void)
{
#ifdef _MSC_VER
return __rdtsc();
#else
uint32_t low,high;
int64_t val;
asm volatile("rdtsc" : "=a" (low), "=d" (high));
@ -565,6 +568,7 @@ static inline int64_t cpu_get_real_ticks(void)
val <<= 32;
val |= low;
return val;
#endif
}
#elif defined(__hppa__)

View File

@ -56,7 +56,7 @@
# define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#if defined(_WIN64)
#if defined(_WIN64) && !defined(_MSC_VER)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default)