# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: package/.../qemu/qemu-0.9.0-gcc4-hacks.patch # Copyright (C) 2007 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- SDE-COPYRIGHT-NOTE-END --- 2007-04-12 rediffed for qemu 0.9.0 2005-10-28 Gwenole Beauchesne * Various additional hacks for GCC4. diff -ruN qemu-0.9.0/cpu-all.h qemu-0.9.0-gcc4-hacks/cpu-all.h --- qemu-0.9.0/cpu-all.h 2007-02-06 00:01:54.000000000 +0100 +++ qemu-0.9.0-gcc4-hacks/cpu-all.h 2007-04-12 17:20:17.000000000 +0200 @@ -339,7 +339,13 @@ static inline void stq_le_p(void *ptr, uint64_t v) { +#if defined(__i386__) && __GNUC__ >= 4 + const union { uint64_t v; uint32_t p[2]; } x = { .v = v }; + ((uint32_t *)ptr)[0] = x.p[0]; + ((uint32_t *)ptr)[1] = x.p[1]; +#else *(uint64_t *)ptr = v; +#endif } /* float access */ diff -ruN qemu-0.9.0/softmmu_header.h qemu-0.9.0-gcc4-hacks/softmmu_header.h --- qemu-0.9.0/softmmu_header.h 2007-02-06 00:01:54.000000000 +0100 +++ qemu-0.9.0-gcc4-hacks/softmmu_header.h 2007-04-12 17:20:17.000000000 +0200 @@ -108,7 +108,7 @@ void REGPARM(2) glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr, DATA_TYPE v, int is_user); #if (DATA_SIZE <= 4) && (TARGET_LONG_BITS == 32) && defined(__i386__) && \ - (ACCESS_TYPE <= 1) && defined(ASM_SOFTMMU) + (ACCESS_TYPE <= 1) && defined(ASM_SOFTMMU) && (__GNUC__ < 4) #define CPU_TLB_ENTRY_BITS 4 @@ -150,7 +150,7 @@ "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MEM_INDEX][0].addr_read)), "i" (CPU_MEM_INDEX), "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) - : "%eax", "%ecx", "%edx", "memory", "cc"); + : "%eax", "%edx", "memory", "cc"); return res; } @@ -197,13 +197,14 @@ "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MEM_INDEX][0].addr_read)), "i" (CPU_MEM_INDEX), "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) - : "%eax", "%ecx", "%edx", "memory", "cc"); + : "%eax", "%edx", "memory", "cc"); return res; } #endif -static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE v) +static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE val) { + RES_TYPE v = val; asm volatile ("movl %0, %%edx\n" "movl %0, %%eax\n" "shrl %3, %%edx\n" @@ -240,16 +241,14 @@ "2:\n" : : "r" (ptr), -/* NOTE: 'q' would be needed as constraint, but we could not use it - with T1 ! */ - "r" (v), + "q" (v), "i" ((CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS), "i" (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS), "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MEM_INDEX][0].addr_write)), "i" (CPU_MEM_INDEX), "m" (*(uint8_t *)&glue(glue(__st, SUFFIX), MMUSUFFIX)) - : "%eax", "%ecx", "%edx", "memory", "cc"); + : "%eax", "%edx", "memory", "cc"); } #else diff -ruN qemu-0.9.0/target-i386/helper.c qemu-0.9.0-gcc4-hacks/target-i386/helper.c --- qemu-0.9.0/target-i386/helper.c 2007-02-06 00:01:54.000000000 +0100 +++ qemu-0.9.0-gcc4-hacks/target-i386/helper.c 2007-04-12 17:20:17.000000000 +0200 @@ -3452,8 +3452,15 @@ nb_xmm_regs = 8 << data64; addr = ptr + 0xa0; for(i = 0; i < nb_xmm_regs; i++) { +#if defined(__i386__) && __GNUC__ >= 4 + env->xmm_regs[i].XMM_L(0) = ldl(addr); + env->xmm_regs[i].XMM_L(1) = ldl(addr + 4); + env->xmm_regs[i].XMM_L(2) = ldl(addr + 8); + env->xmm_regs[i].XMM_L(3) = ldl(addr + 12); +#else env->xmm_regs[i].XMM_Q(0) = ldq(addr); env->xmm_regs[i].XMM_Q(1) = ldq(addr + 8); +#endif addr += 16; } } diff -ruN qemu-0.9.0/target-i386/ops_sse.h qemu-0.9.0-gcc4-hacks/target-i386/ops_sse.h --- qemu-0.9.0/target-i386/ops_sse.h 2007-02-06 00:01:54.000000000 +0100 +++ qemu-0.9.0-gcc4-hacks/target-i386/ops_sse.h 2007-04-12 17:20:17.000000000 +0200 @@ -34,6 +34,12 @@ #define Q(n) XMM_Q(n) #define SUFFIX _xmm #endif +#if defined(__i386__) && __GNUC__ >= 4 +#define RegCopy(d, s) __builtin_memcpy(&(d), &(s), sizeof(d)) +#endif +#ifndef RegCopy +#define RegCopy(d, s) d = s +#endif void OPPROTO glue(op_psrlw, SUFFIX)(void) { @@ -589,7 +595,7 @@ r.W(1) = s->W((order >> 2) & 3); r.W(2) = s->W((order >> 4) & 3); r.W(3) = s->W((order >> 6) & 3); - *d = r; + RegCopy(*d, r); } #else void OPPROTO op_shufps(void)