w64: Improve compilation with MinGW-w64
cover w64: Improve compilation with MinGW-w64
These patches are a step towards full 64 bit support for w64. The patches 4 and 5 are optional.
Please apply this series.
Thanks,
Stefan Weil
[PATCH 1/6] w64: Fix size of ram_addr_t
[PATCH 2/6] tcg: Rearrange definitions and include statements [PATCH 3/6] w64: Fix data type of parameters for flush_icache_range [PATCH 4/6] w64: Change data type of parameters for [PATCH 5/6] cache-utils: Change data type of parameters for [PATCH 6/6] w64: fix type casts when calling flush_icache_range
PATCH 1/6 w64: Fix size of ram_addr_t
ram_addr_t must be large enough to address any address of the host.
For hosts with sizeof(unsigned long) == sizeof(void *), this patch changes nothing. All currently supported hosts fall into this category.
For w64 hosts, sizeof(unsigned long) is 4 while sizeof(void *) is 8, so the use of uintptr_t is needed.
--- cpu-common.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
cpu-common.h +3 -3
@@ -28,9 +28,9 @@ typedef uint64_t ram_addr_t;# define RAM_ADDR_MAX UINT64_MAX# define RAM_ADDR_FMT "%" PRIx64#else -typedef unsigned long ram_addr_t ; -# define RAM_ADDR_MAX ULONG_MAX -# define RAM_ADDR_FMT "%lx" +typedef uintptr_t ram_addr_t ; +# define RAM_ADDR_MAX UINTPTR_MAX +# define RAM_ADDR_FMT "%" PRIxPTR#endif /* memory API */
Signature · 1 line
1.7.9
PATCH 2/6 tcg: Rearrange definitions and include statements
In reply to Stefan WeilThis change makes tcg_target_ulong available in tcg-target.h.
--- tcg/tcg.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
tcg/tcg.h +3 -3
@@ -32,9 +32,6 @@# error Unknown pointer size for tcg target#endif -#include "tcg-target.h" -#include "tcg-runtime.h" -#if TCG_TARGET_REG_BITS ==32 typedef int32_t tcg_target_long ;typedef uint32_t tcg_target_ulong ;
@@ -49,6 +46,9 @@ typedef uint64_t tcg_target_ulong;#error unsupported#endif +#include "tcg-target.h" +#include "tcg-runtime.h" +#if TCG_TARGET_NB_REGS <=32 typedef uint32_t TCGRegSet ;#elif TCG_TARGET_NB_REGS <=64
Signature · 1 line
1.7.9
PATCH 3/6 w64: Fix data type of parameters for flush_icache_range
In reply to Stefan Weilflush_icache_range takes two address parameters which must be large enough to address any address of the host.
For hosts with sizeof(unsigned long) == sizeof(void *), this patch changes nothing. All currently supported hosts fall into this category.
For w64 hosts, sizeof(unsigned long) is 4 while sizeof(void *) is 8, so the use of tcg_target_ulong is needed for i386 and tci (the tcg targets which work with w64).
--- tcg/i386/tcg-target.h | 3 ++- tcg/tci/tcg-target.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
tcg/i386/tcg-target.h +2 -1
@@ -123,6 +123,7 @@ typedef enum {# define TCG_AREG0 TCG_REG_EBP#endif -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) { }
tcg/tci/tcg-target.h +2 -1
@@ -157,7 +157,8 @@ void tci_disas(uint8_t opc);unsigned long tcg_qemu_tb_exec (CPUState *env,uint8_t *tb_ptr);#define tcg_qemu_tb_exec tcg_qemu_tb_exec -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) { }
Signature · 1 line
1.7.9
PATCH 4/6 w64: Change data type of parameters for flush_icache_range
In reply to Stefan WeilThe TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed for the other TCG targets, but it can be applied to avoid code differences.
--- tcg/arm/tcg-target.h | 3 ++- tcg/hppa/tcg-target.h | 4 +++- tcg/ia64/tcg-target.h | 3 ++- tcg/mips/tcg-target.h | 3 ++- tcg/s390/tcg-target.h | 3 ++- tcg/sparc/tcg-target.h | 3 ++- 6 files changed, 13 insertions(+), 6 deletions(-)
tcg/arm/tcg-target.h +2 -1
@@ -81,7 +81,8 @@ enum { TCG_AREG0 = TCG_REG_R6, }; -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) {#if QEMU_GNUC_PREREQ (4 ,1 )__builtin___clear_cache ((char *) start, (char *) stop);
tcg/hppa/tcg-target.h +3 -1
@@ -107,7 +107,9 @@ typedef enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R17 -static inline void flush_icache_range (unsigned long start,unsigned long stop) + +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) { start &= ~31 ;while (start <= stop) {
tcg/ia64/tcg-target.h +2 -1
@@ -146,7 +146,8 @@ typedef enum {/* Guest base is supported */ #define TCG_TARGET_HAS_GUEST_BASE -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) { start = start & ~(32UL -1UL ); stop = (stop + (32UL -1UL )) & ~(32UL -1UL );
tcg/mips/tcg-target.h +2 -1
@@ -108,7 +108,8 @@ typedef enum {#include <sys/cachectl.h> #endif -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) {cacheflush ((void *)start, stop-start,ICACHE ); }
tcg/s390/tcg-target.h +2 -1
@@ -100,6 +100,7 @@ enum { TCG_AREG0 = TCG_REG_R10, }; -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) { }
tcg/sparc/tcg-target.h +2 -1
@@ -134,7 +134,8 @@ typedef enum {#define TCG_AREG0 TCG_REG_G6#endif -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (tcg_target_ulong start, +tcg_target_ulong stop) {unsigned long p;
Signature · 1 line
1.7.9
PATCH 5/6 cache-utils: Change data type of parameters for flush_icache_range
In reply to Stefan WeilThe TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed here, but it can be applied to avoid code differences.
--- cache-utils.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cache-utils.h +1 -1
@@ -12,7 +12,7 @@ extern struct qemu_cache_conf qemu_cache_conf;void qemu_cache_utils_init (char **envp);/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (uintptr_t start,uintptr_t stop) {unsigned long p, start1, stop1;unsigned long dsize = qemu_cache_conf.dcache_bsize;
Signature · 1 line
1.7.9
Re: [Qemu-devel] [PATCH 5/6] cache-utils: Change data type of parameters for flush_icache_range
Quoted 5 lines · Stefan Weil
The TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed here, but it can be applied to avoid code differences.
Both 4 and 5 look reasonable to me.
Alex
Re: [Qemu-devel] [PATCH 5/6] cache-utils: Change data type of parameters for flush_icache_range
In reply to Stefan WeilQuoted 17 lines · Stefan Weil
The TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed here, but it can be applied to avoid code differences.
Cc Alexander Graf<[email protected]>Signed-off-by Stefan Weil<[email protected]>--- cache-utils.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)cache-utils.h +0
-0
cache-utils.h extern struct qemu_cache_conf qemu_cache_conf; · line 15
Quoted 5 lines
cache-utils.h +1
-1@@ -12,7 +12,7 @@ extern struct qemu_cache_conf qemu_cache_conf;void qemu_cache_utils_init (char **envp);/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (uintptr_t start,uintptr_t stop)
Ugh, this causes compilation breakage:
CC cache-utils.o
In file included from cache-utils.c:1:
cache-utils.h:15: error: expected ‘)’ before ‘start’
make: *** [cache-utils.o] Error 1
because cache-utils.c doesn't include anything that would define uintptr_t. Any idea how to fix this?
Alex
Re: [Qemu-devel] [PATCH 5/6] cache-utils: Change data type of parameters for flush_icache_range
Am 05.03.2012 19:57, schrieb Alexander Graf:
Quoted 32 lines · Stefan Weil
Quoted 17 lines
The TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed here, but it can be applied to avoid code differences.
Cc Alexander Graf<[email protected]>Signed-off-by Stefan Weil<[email protected]>--- cache-utils.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)cache-utils.h +0
-0cache-utils.h extern struct qemu_cache_conf qemu_cache_conf; · line 16
Quoted 6 lines
cache-utils.h +1
-1@@ -12,7 +12,7 @@ extern struct qemu_cache_conf qemu_cache_conf;void qemu_cache_utils_init (char **envp);/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (uintptr_t start,uintptr_t stop)Ugh, this causes compilation breakage:
CC cache-utils.o
In file included from cache-utils.c:1:
cache-utils.h:15: error: expected ‘)’ before ‘start’
make: *** [cache-utils.o] Error 1
Quoted 4 lines
because
cache-utils.cdoesn't include anything that would defineuintptr_t. Any idea how to fix this?Alex
#include <stdint.h>
Cheers,
Stefan
Re: [Qemu-devel] [PATCH 5/6] cache-utils: Change data type of parameters for flush_icache_range
Quoted 32 lines · Stefan Weil
Am 05.03.2012 19:57, schrieb Alexander Graf:
Quoted 31 lines · Stefan Weil
Quoted 17 lines
The TCG targets i386 and tci needed a change of the function prototype for w64.
This change is currently not needed here, but it can be applied to avoid code differences.
Cc Alexander Graf<[email protected]>Signed-off-by Stefan Weil<[email protected]>--- cache-utils.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)cache-utils.h +0
-0cache-utils.h extern struct qemu_cache_conf qemu_cache_conf; · line 15
Quoted 5 lines
cache-utils.h +1
-1@@ -12,7 +12,7 @@ extern struct qemu_cache_conf qemu_cache_conf;void qemu_cache_utils_init (char **envp);/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range (unsigned long start,unsigned long stop) +static inline void flush_icache_range (uintptr_t start,uintptr_t stop)Ugh, this causes compilation breakage:
CC cache-utils.o
In file included from cache-utils.c:1:
cache-utils.h:15: error: expected �e)�f before �estart�f
make: *** [cache-utils.o] Error 1
Quoted 7 lines
Quoted 4 lines
because
cache-utils.cdoesn't include anything that would defineuintptr_t. Any idea how to fix this?Alex
#include <
stdint.h>
Mind to send a patch? ;)
Alex
Quoted 6 lines
Cheers,
Stefan
PATCH 1/1 cache-utils: Add missing include file for uintptr_t
Commit 021ecd8b9db37927059f5d3234b51ed766706437 breaks the build for PPC hosts because it uses uintptr_t without the necessary include file.
uintptr_t is defined in stdint.h, so add this include.
---
Hi Alex,
could you please test whether my patch fixes the build problem?
Thanks,
Stefan
cache-utils.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
cache-utils.h +3 -0
@@ -2,6 +2,9 @@#define QEMU_CACHE_UTILS_H #if defined(_ARCH_PPC) + +#include <stdint.h> /* uintptr_t */ + struct qemu_cache_conf { unsigned long dcache_bsize; unsigned long icache_bsize;
Signature · 1 line
1.7.9
Re: [Qemu-devel] [PATCH] cache-utils: Add missing include file for uintptr_t
Quoted 5 lines · Stefan Weil
Commit
021ecd8b9db37927059f5d3234b51ed766706437breaks the build for PPC hosts because it usesuintptr_twithout the necessary include file.
uintptr_tis defined instdint.h, so add this include.
Quoted 7 lines
Cc Alexander Graf <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
Hi Alex,
could you please test whether my patch fixes the build problem?
Yup, that one fixes it :). Thanks!
Alex
Blue Swirl
AppliedRe: [Qemu-devel] [PATCH] cache-utils: Add missing include file for uintptr_t
In reply to Stefan WeilThanks, applied.
Quoted 37 lines · Stefan Weil
Commit
021ecd8b9db37927059f5d3234b51ed766706437breaks the build for PPC hosts because it usesuintptr_twithout the necessary include file.
uintptr_tis defined instdint.h, so add this include.Cc Alexander Graf <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
Hi Alex,
could you please test whether my patch fixes the build problem?
Thanks,
Stefancache-utils.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)cache-utils.h +3
-1@@ -2,6 +2,9 @@ #define QEMU_CACHE_UTILS_H #if defined(_ARCH_PPC) + +#include <stdint.h> /* uintptr_t */ + struct qemu_cache_conf { unsigned long dcache_bsize; unsigned long icache_bsize; --1.7.9
PATCH 6/6 w64: fix type casts when calling flush_icache_range
In reply to Stefan Weil--- tcg/tcg.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
tcg/tcg.c +5 -4
@@ -253,8 +253,8 @@ void tcg_prologue_init(TCGContext *s) s->code_buf = code_gen_prologue; s->code_ptr = s->code_buf;tcg_target_qemu_prologue (s); -flush_icache_range ((unsigned long )s->code_buf, - (unsigned long )s->code_ptr); +flush_icache_range ((tcg_target_ulong )s->code_buf, + (tcg_target_ulong )s->code_ptr); } void tcg_set_frame(TCGContext *s, int reg,
@@ -2176,8 +2176,9 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)tcg_gen_code_common (s, gen_code_buf,-1 );/* flush instruction cache */ -flush_icache_range ((unsigned long )gen_code_buf, - (unsigned long )s->code_ptr); +flush_icache_range ((tcg_target_ulong )gen_code_buf, + (tcg_target_ulong )s->code_ptr); +return s->code_ptr - gen_code_buf; }
Signature · 1 line
1.7.9
Blue Swirl
AppliedThanks, applied all.
Quoted 15 lines · Stefan Weil
These patches are a step towards full 64 bit support for w64. The patches 4 and 5 are optional.
Please apply this series.
Thanks,
Stefan Weil[PATCH 1/6] w64: Fix size of
ram_addr_t
[PATCH 2/6] tcg: Rearrange definitions and include statements [PATCH 3/6] w64: Fix data type of parameters forflush_icache_range[PATCH 4/6] w64: Change data type of parameters for [PATCH 5/6] cache-utils: Change data type of parameters for [PATCH 6/6] w64: fix type casts when callingflush_icache_range