Commit e777e89c4be2b80b37043e72fe6158da5ea4bf6c

Authored by Filip Navara
1 parent 82642adc

Win64 host port

- Change long/unsigned long to intptr_t/uintptr_t where needed
- Use PRIuPTR instead of %zu for printf
- Rework parsing of UUIDs
- Add support for Win64 ABI to TCG
arm-semi.c
... ... @@ -37,6 +37,7 @@
37 37 #include "gdbstub.h"
38 38 #endif
39 39  
  40 +#undef SYS_OPEN
40 41 #define SYS_OPEN 0x01
41 42 #define SYS_CLOSE 0x02
42 43 #define SYS_WRITEC 0x03
... ...
audio/audio.c
... ... @@ -192,7 +192,8 @@ void *audio_calloc (const char *funcname, int nmemb, size_t size)
192 192 if (audio_bug ("audio_calloc", cond)) {
193 193 AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n",
194 194 funcname);
195   - AUD_log (NULL, "nmemb=%d size=%zu (len=%zu)\n", nmemb, size, len);
  195 + AUD_log (NULL, "nmemb=%d size=%" PRIuPTR " (len=%" PRIuPTR ")\n",
  196 + nmemb, size, len);
196 197 return NULL;
197 198 }
198 199  
... ... @@ -804,8 +805,8 @@ static int audio_attach_capture (HWVoiceOut *hw)
804 805  
805 806 sc = audio_calloc (AUDIO_FUNC, 1, sizeof (*sc));
806 807 if (!sc) {
807   - dolog ("Could not allocate soft capture voice (%zu bytes)\n",
808   - sizeof (*sc));
  808 + dolog ("Could not allocate soft capture voice (%" PRIuPTR
  809 + " bytes)\n", sizeof (*sc));
809 810 return -1;
810 811 }
811 812  
... ... @@ -1830,8 +1831,8 @@ CaptureVoiceOut *AUD_add_capture (
1830 1831  
1831 1832 cb = audio_calloc (AUDIO_FUNC, 1, sizeof (*cb));
1832 1833 if (!cb) {
1833   - dolog ("Could not allocate capture callback information, size %zu\n",
1834   - sizeof (*cb));
  1834 + dolog ("Could not allocate capture callback information, size %"
  1835 + PRIuPTR "\n", sizeof (*cb));
1835 1836 goto err0;
1836 1837 }
1837 1838 cb->ops = *ops;
... ... @@ -1848,7 +1849,7 @@ CaptureVoiceOut *AUD_add_capture (
1848 1849  
1849 1850 cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));
1850 1851 if (!cap) {
1851   - dolog ("Could not allocate capture voice, size %zu\n",
  1852 + dolog ("Could not allocate capture voice, size %" PRIuPTR "\n",
1852 1853 sizeof (*cap));
1853 1854 goto err1;
1854 1855 }
... ...
audio/audio_template.h
... ... @@ -350,7 +350,7 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
350 350  
351 351 sw = audio_calloc (AUDIO_FUNC, 1, sizeof (*sw));
352 352 if (!sw) {
353   - dolog ("Could not allocate soft voice `%s' (%zu bytes)\n",
  353 + dolog ("Could not allocate soft voice `%s' (%" PRIuPTR " bytes)\n",
354 354 sw_name ? sw_name : "unknown", sizeof (*sw));
355 355 goto err1;
356 356 }
... ...
audio/mixeng.c
... ... @@ -301,7 +301,8 @@ void *st_rate_start (int inrate, int outrate)
301 301 struct rate *rate = audio_calloc (AUDIO_FUNC, 1, sizeof (*rate));
302 302  
303 303 if (!rate) {
304   - dolog ("Could not allocate resampler (%zu bytes)\n", sizeof (*rate));
  304 + dolog ("Could not allocate resampler (%" PRIuPTR " bytes)\n",
  305 + sizeof (*rate));
305 306 return NULL;
306 307 }
307 308  
... ...
block/qcow2.c
... ... @@ -96,8 +96,8 @@ static int qcow_read_extensions(BlockDriverState *bs, uint64_t start_offset,
96 96 #endif
97 97  
98 98 if (bdrv_pread(s->hd, offset, &ext, sizeof(ext)) != sizeof(ext)) {
99   - fprintf(stderr, "qcow_handle_extension: ERROR: pread fail from offset %llu\n",
100   - (unsigned long long)offset);
  99 + fprintf(stderr, "qcow_handle_extension: ERROR: pread fail from"
  100 + " offset %" PRIu64 "\n", offset);
101 101 return 1;
102 102 }
103 103 be32_to_cpus(&ext.magic);
... ... @@ -113,7 +113,7 @@ static int qcow_read_extensions(BlockDriverState *bs, uint64_t start_offset,
113 113 case QCOW_EXT_MAGIC_BACKING_FORMAT:
114 114 if (ext.len >= sizeof(bs->backing_format)) {
115 115 fprintf(stderr, "ERROR: ext_backing_format: len=%u too large"
116   - " (>=%zu)\n",
  116 + " (>=%" PRIuPTR ")\n",
117 117 ext.len, sizeof(bs->backing_format));
118 118 return 2;
119 119 }
... ...
cache-utils.h
... ... @@ -12,11 +12,11 @@ extern struct qemu_cache_conf qemu_cache_conf;
12 12 extern void qemu_cache_utils_init(char **envp);
13 13  
14 14 /* mildly adjusted code from tcg-dyngen.c */
15   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  15 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
16 16 {
17   - unsigned long p, start1, stop1;
18   - unsigned long dsize = qemu_cache_conf.dcache_bsize;
19   - unsigned long isize = qemu_cache_conf.icache_bsize;
  17 + uintptr_t p, start1, stop1;
  18 + uintptr_t dsize = qemu_cache_conf.dcache_bsize;
  19 + uintptr_t isize = qemu_cache_conf.icache_bsize;
20 20  
21 21 start1 = start & ~(dsize - 1);
22 22 stop1 = (stop + dsize - 1) & ~(dsize - 1);
... ...
cpu-all.h
... ... @@ -651,8 +651,8 @@ extern int have_guest_base;
651 651 #else /* !CONFIG_USER_ONLY */
652 652 /* NOTE: we use double casts if pointers and target_ulong have
653 653 different sizes */
654   -#define saddr(x) (uint8_t *)(long)(x)
655   -#define laddr(x) (uint8_t *)(long)(x)
  654 +#define saddr(x) (uint8_t *)(intptr_t)(x)
  655 +#define laddr(x) (uint8_t *)(intptr_t)(x)
656 656 #endif
657 657  
658 658 #define ldub_raw(p) ldub_p(laddr((p)))
... ...
cpu-defs.h
... ... @@ -141,8 +141,8 @@ typedef struct CPUWatchpoint {
141 141 /* in order to avoid passing too many arguments to the MMIO \
142 142 helpers, we store some rarely used information in the CPU \
143 143 context) */ \
144   - unsigned long mem_io_pc; /* host pc at which the memory was \
145   - accessed */ \
  144 + uintptr_t mem_io_pc; /* host pc at which the memory was \
  145 + accessed */ \
146 146 target_ulong mem_io_vaddr; /* target virtual addr at which the \
147 147 memory was accessed */ \
148 148 uint32_t halted; /* Nonzero if the CPU is in suspend state */ \
... ...
cpu-exec.c
... ... @@ -94,7 +94,7 @@ void cpu_resume_from_signal(CPUState *env1, void *puc)
94 94 could be used if available. */
95 95 static void cpu_exec_nocache(int max_cycles, TranslationBlock *orig_tb)
96 96 {
97   - unsigned long next_tb;
  97 + uintptr_t next_tb;
98 98 TranslationBlock *tb;
99 99  
100 100 /* Should never happen.
... ... @@ -213,7 +213,7 @@ int cpu_exec(CPUState *env1)
213 213 int ret, interrupt_request;
214 214 TranslationBlock *tb;
215 215 uint8_t *tc_ptr;
216   - unsigned long next_tb;
  216 + uintptr_t next_tb;
217 217  
218 218 if (cpu_halted(env1) == EXCP_HALTED)
219 219 return EXCP_HALTED;
... ... @@ -608,8 +608,8 @@ int cpu_exec(CPUState *env1)
608 608 tb_invalidated_flag = 0;
609 609 }
610 610 #ifdef CONFIG_DEBUG_EXEC
611   - qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
612   - (long)tb->tc_ptr, tb->pc,
  611 + qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08Ix [" TARGET_FMT_lx "] %s\n",
  612 + (intptr_t)tb->tc_ptr, tb->pc,
613 613 lookup_symbol(tb->pc));
614 614 #endif
615 615 /* see if we can patch the calling TB. When the TB
... ... @@ -647,7 +647,7 @@ int cpu_exec(CPUState *env1)
647 647 if ((next_tb & 3) == 2) {
648 648 /* Instruction counter expired. */
649 649 int insns_left;
650   - tb = (TranslationBlock *)(long)(next_tb & ~3);
  650 + tb = (TranslationBlock *)(intptr_t)(next_tb & ~3);
651 651 /* Restore PC. */
652 652 cpu_pc_from_tb(env, tb);
653 653 insns_left = env->icount_decr.u32;
... ...
... ... @@ -235,7 +235,7 @@ void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)
235 235 /* Disassemble this for me please... (debugging). */
236 236 void disas(FILE *out, void *code, unsigned long size)
237 237 {
238   - unsigned long pc;
  238 + uintptr_t pc;
239 239 int count;
240 240 struct disassemble_info disasm_info;
241 241 int (*print_insn)(bfd_vma pc, disassemble_info *info);
... ... @@ -243,7 +243,7 @@ void disas(FILE *out, void *code, unsigned long size)
243 243 INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
244 244  
245 245 disasm_info.buffer = code;
246   - disasm_info.buffer_vma = (unsigned long)code;
  246 + disasm_info.buffer_vma = (uintptr_t)code;
247 247 disasm_info.buffer_length = size;
248 248  
249 249 #ifdef HOST_WORDS_BIGENDIAN
... ... @@ -283,8 +283,8 @@ void disas(FILE *out, void *code, unsigned long size)
283 283 (long) code);
284 284 return;
285 285 #endif
286   - for (pc = (unsigned long)code; size > 0; pc += count, size -= count) {
287   - fprintf(out, "0x%08lx: ", pc);
  286 + for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) {
  287 + fprintf(out, "0x%08Ix: ", pc);
288 288 #ifdef __arm__
289 289 /* since data is included in the code, it is better to
290 290 display code data too */
... ...
dyngen-exec.h
... ... @@ -94,13 +94,13 @@ extern int printf(const char *, ...);
94 94 /* The return address may point to the start of the next instruction.
95 95 Subtracting one gets us the call instruction itself. */
96 96 #if defined(__s390__)
97   -# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
  97 +# define GETPC() ((void*)(((uintptr_t)__builtin_return_address(0) & 0x7fffffffUL) - 1))
98 98 #elif defined(__arm__)
99 99 /* Thumb return addresses have the low bit set, so we need to subtract two.
100 100 This is still safe in ARM mode because instructions are 4 bytes. */
101   -# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
  101 +# define GETPC() ((void *)((uintptr_t)__builtin_return_address(0) - 2))
102 102 #else
103   -# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
  103 +# define GETPC() ((void *)((uintptr_t)__builtin_return_address(0) - 1))
104 104 #endif
105 105  
106 106 #endif /* !defined(__DYNGEN_EXEC_H__) */
... ...
exec-all.h
... ... @@ -61,17 +61,17 @@ extern uint32_t gen_opc_hflags[OPC_BUF_SIZE];
61 61 void gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
62 62 void gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
63 63 void gen_pc_load(CPUState *env, struct TranslationBlock *tb,
64   - unsigned long searched_pc, int pc_pos, void *puc);
  64 + uintptr_t searched_pc, int pc_pos, void *puc);
65 65  
66   -unsigned long code_gen_max_block_size(void);
  66 +uintptr_t code_gen_max_block_size(void);
67 67 void cpu_gen_init(void);
68 68 int cpu_gen_code(CPUState *env, struct TranslationBlock *tb,
69 69 int *gen_code_size_ptr);
70 70 int cpu_restore_state(struct TranslationBlock *tb,
71   - CPUState *env, unsigned long searched_pc,
  71 + CPUState *env, uintptr_t searched_pc,
72 72 void *puc);
73 73 int cpu_restore_state_copy(struct TranslationBlock *tb,
74   - CPUState *env, unsigned long searched_pc,
  74 + CPUState *env, uintptr_t searched_pc,
75 75 void *puc);
76 76 void cpu_resume_from_signal(CPUState *env1, void *puc);
77 77 void cpu_io_recompile(CPUState *env, void *retaddr);
... ... @@ -80,7 +80,7 @@ TranslationBlock *tb_gen_code(CPUState *env,
80 80 int cflags);
81 81 void cpu_exec_init(CPUState *env);
82 82 void QEMU_NORETURN cpu_loop_exit(void);
83   -int page_unprotect(target_ulong address, unsigned long pc, void *puc);
  83 +int page_unprotect(target_ulong address, uintptr_t pc, void *puc);
84 84 void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t end,
85 85 int is_cpu_write_access);
86 86 void tb_invalidate_page_range(target_ulong start, target_ulong end);
... ... @@ -142,7 +142,7 @@ struct TranslationBlock {
142 142 #ifdef USE_DIRECT_JUMP
143 143 uint16_t tb_jmp_offset[2]; /* offset of jump instruction */
144 144 #else
145   - unsigned long tb_next[2]; /* address of jump generated code */
  145 + uintptr_t tb_next[2]; /* address of jump generated code */
146 146 #endif
147 147 /* list of TBs jumping to this one. This is a circular list using
148 148 the two least significant bits of the pointers to tell what is
... ... @@ -168,7 +168,7 @@ static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc)
168 168 | (tmp & TB_JMP_ADDR_MASK));
169 169 }
170 170  
171   -static inline unsigned int tb_phys_hash_func(unsigned long pc)
  171 +static inline unsigned int tb_phys_hash_func(uintptr_t pc)
172 172 {
173 173 return pc & (CODE_GEN_PHYS_HASH_SIZE - 1);
174 174 }
... ... @@ -187,17 +187,17 @@ extern int code_gen_max_blocks;
187 187 #if defined(USE_DIRECT_JUMP)
188 188  
189 189 #if defined(_ARCH_PPC)
190   -extern void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr);
  190 +extern void ppc_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr);
191 191 #define tb_set_jmp_target1 ppc_tb_set_jmp_target
192 192 #elif defined(__i386__) || defined(__x86_64__)
193   -static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
  193 +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr)
194 194 {
195 195 /* patch the branch destination */
196 196 *(uint32_t *)jmp_addr = addr - (jmp_addr + 4);
197 197 /* no need to flush icache explicitly */
198 198 }
199 199 #elif defined(__arm__)
200   -static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
  200 +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr)
201 201 {
202 202 #if QEMU_GNUC_PREREQ(4, 1)
203 203 void __clear_cache(char *beg, char *end);
... ... @@ -223,19 +223,19 @@ static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr
223 223 #endif
224 224  
225 225 static inline void tb_set_jmp_target(TranslationBlock *tb,
226   - int n, unsigned long addr)
  226 + int n, uintptr_t addr)
227 227 {
228   - unsigned long offset;
  228 + uintptr_t offset;
229 229  
230 230 offset = tb->tb_jmp_offset[n];
231   - tb_set_jmp_target1((unsigned long)(tb->tc_ptr + offset), addr);
  231 + tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr);
232 232 }
233 233  
234 234 #else
235 235  
236 236 /* set the jump target */
237 237 static inline void tb_set_jmp_target(TranslationBlock *tb,
238   - int n, unsigned long addr)
  238 + int n, uintptr_t addr)
239 239 {
240 240 tb->tb_next[n] = addr;
241 241 }
... ... @@ -248,15 +248,15 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
248 248 /* NOTE: this test is only needed for thread safety */
249 249 if (!tb->jmp_next[n]) {
250 250 /* patch the native jump address */
251   - tb_set_jmp_target(tb, n, (unsigned long)tb_next->tc_ptr);
  251 + tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr);
252 252  
253 253 /* add in TB jmp circular list */
254 254 tb->jmp_next[n] = tb_next->jmp_first;
255   - tb_next->jmp_first = (TranslationBlock *)((long)(tb) | (n));
  255 + tb_next->jmp_first = (TranslationBlock *)((uintptr_t)(tb) | (n));
256 256 }
257 257 }
258 258  
259   -TranslationBlock *tb_find_pc(unsigned long pc_ptr);
  259 +TranslationBlock *tb_find_pc(uintptr_t pc_ptr);
260 260  
261 261 extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
262 262 extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
... ... @@ -325,7 +325,7 @@ static inline target_ulong get_phys_addr_code(CPUState *env1, target_ulong addr)
325 325 cpu_abort(env1, "Trying to execute code outside RAM or ROM at 0x" TARGET_FMT_lx "\n", addr);
326 326 #endif
327 327 }
328   - p = (void *)(unsigned long)addr
  328 + p = (void *)(uintptr_t)addr
329 329 + env1->tlb_table[mmu_idx][page_index].addend;
330 330 return qemu_ram_addr_from_host(p);
331 331 }
... ...
... ... @@ -706,8 +706,8 @@ static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
706 706  
707 707 for(;;) {
708 708 tb1 = *ptb;
709   - n1 = (long)tb1 & 3;
710   - tb1 = (TranslationBlock *)((long)tb1 & ~3);
  709 + n1 = (intptr_t)tb1 & 3;
  710 + tb1 = (TranslationBlock *)((intptr_t)tb1 & ~3);
711 711 if (tb1 == tb) {
712 712 *ptb = tb1->page_next[n1];
713 713 break;
... ... @@ -727,8 +727,8 @@ static inline void tb_jmp_remove(TranslationBlock *tb, int n)
727 727 /* find tb(n) in circular list */
728 728 for(;;) {
729 729 tb1 = *ptb;
730   - n1 = (long)tb1 & 3;
731   - tb1 = (TranslationBlock *)((long)tb1 & ~3);
  730 + n1 = (intptr_t)tb1 & 3;
  731 + tb1 = (TranslationBlock *)((intptr_t)tb1 & ~3);
732 732 if (n1 == n && tb1 == tb)
733 733 break;
734 734 if (n1 == 2) {
... ... @@ -748,7 +748,7 @@ static inline void tb_jmp_remove(TranslationBlock *tb, int n)
748 748 another TB */
749 749 static inline void tb_reset_jump(TranslationBlock *tb, int n)
750 750 {
751   - tb_set_jmp_target(tb, n, (unsigned long)(tb->tc_ptr + tb->tb_next_offset[n]));
  751 + tb_set_jmp_target(tb, n, (uintptr_t)(tb->tc_ptr + tb->tb_next_offset[n]));
752 752 }
753 753  
754 754 void tb_phys_invalidate(TranslationBlock *tb, target_ulong page_addr)
... ... @@ -793,16 +793,16 @@ void tb_phys_invalidate(TranslationBlock *tb, target_ulong page_addr)
793 793 /* suppress any remaining jumps to this TB */
794 794 tb1 = tb->jmp_first;
795 795 for(;;) {
796   - n1 = (long)tb1 & 3;
  796 + n1 = (intptr_t)tb1 & 3;
797 797 if (n1 == 2)
798 798 break;
799   - tb1 = (TranslationBlock *)((long)tb1 & ~3);
  799 + tb1 = (TranslationBlock *)((intptr_t)tb1 & ~3);
800 800 tb2 = tb1->jmp_next[n1];
801 801 tb_reset_jump(tb1, n1);
802 802 tb1->jmp_next[n1] = NULL;
803 803 tb1 = tb2;
804 804 }
805   - tb->jmp_first = (TranslationBlock *)((long)tb | 2); /* fail safe */
  805 + tb->jmp_first = (TranslationBlock *)((intptr_t)tb | 2); /* fail safe */
806 806  
807 807 tb_phys_invalidate_count++;
808 808 }
... ... @@ -843,8 +843,8 @@ static void build_page_bitmap(PageDesc *p)
843 843  
844 844 tb = p->first_tb;
845 845 while (tb != NULL) {
846   - n = (long)tb & 3;
847   - tb = (TranslationBlock *)((long)tb & ~3);
  846 + n = (intptr_t)tb & 3;
  847 + tb = (TranslationBlock *)((intptr_t)tb & ~3);
848 848 /* NOTE: this is subtle as a TB may span two physical pages */
849 849 if (n == 0) {
850 850 /* NOTE: tb_end may be after the end of the page, but
... ... @@ -887,7 +887,7 @@ TranslationBlock *tb_gen_code(CPUState *env,
887 887 tb->flags = flags;
888 888 tb->cflags = cflags;
889 889 cpu_gen_code(env, tb, &code_gen_size);
890   - code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
  890 + code_gen_ptr = (void *)(((uintptr_t)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
891 891  
892 892 /* check next page if needed */
893 893 virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
... ... @@ -935,8 +935,8 @@ void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t
935 935 /* XXX: see if in some cases it could be faster to invalidate all the code */
936 936 tb = p->first_tb;
937 937 while (tb != NULL) {
938   - n = (long)tb & 3;
939   - tb = (TranslationBlock *)((long)tb & ~3);
  938 + n = (intptr_t)tb & 3;
  939 + tb = (TranslationBlock *)((intptr_t)tb & ~3);
940 940 tb_next = tb->page_next[n];
941 941 /* NOTE: this is subtle as a TB may span two physical pages */
942 942 if (n == 0) {
... ... @@ -1039,7 +1039,7 @@ static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int le
1039 1039  
1040 1040 #if !defined(CONFIG_SOFTMMU)
1041 1041 static void tb_invalidate_phys_page(target_phys_addr_t addr,
1042   - unsigned long pc, void *puc)
  1042 + uintptr_t pc, void *puc)
1043 1043 {
1044 1044 TranslationBlock *tb;
1045 1045 PageDesc *p;
... ... @@ -1064,8 +1064,8 @@ static void tb_invalidate_phys_page(target_phys_addr_t addr,
1064 1064 }
1065 1065 #endif
1066 1066 while (tb != NULL) {
1067   - n = (long)tb & 3;
1068   - tb = (TranslationBlock *)((long)tb & ~3);
  1067 + n = (intptr_t)tb & 3;
  1068 + tb = (TranslationBlock *)((intptr_t)tb & ~3);
1069 1069 #ifdef TARGET_HAS_PRECISE_SMC
1070 1070 if (current_tb == tb &&
1071 1071 (current_tb->cflags & CF_COUNT_MASK) != 1) {
... ... @@ -1109,7 +1109,7 @@ static inline void tb_alloc_page(TranslationBlock *tb,
1109 1109 p = page_find_alloc(page_addr >> TARGET_PAGE_BITS);
1110 1110 tb->page_next[n] = p->first_tb;
1111 1111 last_first_tb = p->first_tb;
1112   - p->first_tb = (TranslationBlock *)((long)tb | n);
  1112 + p->first_tb = (TranslationBlock *)((intptr_t)tb | n);
1113 1113 invalidate_page_bitmap(p);
1114 1114  
1115 1115 #if defined(TARGET_HAS_SMC) || 1
... ... @@ -1203,7 +1203,7 @@ void tb_link_phys(TranslationBlock *tb,
1203 1203 else
1204 1204 tb->page_addr[1] = -1;
1205 1205  
1206   - tb->jmp_first = (TranslationBlock *)((long)tb | 2);
  1206 + tb->jmp_first = (TranslationBlock *)((intptr_t)tb | 2);
1207 1207 tb->jmp_next[0] = NULL;
1208 1208 tb->jmp_next[1] = NULL;
1209 1209  
... ... @@ -1221,16 +1221,16 @@ void tb_link_phys(TranslationBlock *tb,
1221 1221  
1222 1222 /* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr <
1223 1223 tb[1].tc_ptr. Return NULL if not found */
1224   -TranslationBlock *tb_find_pc(unsigned long tc_ptr)
  1224 +TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
1225 1225 {
1226 1226 int m_min, m_max, m;
1227   - unsigned long v;
  1227 + uintptr_t v;
1228 1228 TranslationBlock *tb;
1229 1229  
1230 1230 if (nb_tbs <= 0)
1231 1231 return NULL;
1232   - if (tc_ptr < (unsigned long)code_gen_buffer ||
1233   - tc_ptr >= (unsigned long)code_gen_ptr)
  1232 + if (tc_ptr < (uintptr_t)code_gen_buffer ||
  1233 + tc_ptr >= (uintptr_t)code_gen_ptr)
1234 1234 return NULL;
1235 1235 /* binary search (cf Knuth) */
1236 1236 m_min = 0;
... ... @@ -1238,7 +1238,7 @@ TranslationBlock *tb_find_pc(unsigned long tc_ptr)
1238 1238 while (m_min <= m_max) {
1239 1239 m = (m_min + m_max) >> 1;
1240 1240 tb = &tbs[m];
1241   - v = (unsigned long)tb->tc_ptr;
  1241 + v = (uintptr_t)tb->tc_ptr;
1242 1242 if (v == tc_ptr)
1243 1243 return tb;
1244 1244 else if (tc_ptr < v) {
... ... @@ -1261,8 +1261,8 @@ static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
1261 1261 if (tb1 != NULL) {
1262 1262 /* find head of list */
1263 1263 for(;;) {
1264   - n1 = (long)tb1 & 3;
1265   - tb1 = (TranslationBlock *)((long)tb1 & ~3);
  1264 + n1 = (intptr_t)tb1 & 3;
  1265 + tb1 = (TranslationBlock *)((intptr_t)tb1 & ~3);
1266 1266 if (n1 == 2)
1267 1267 break;
1268 1268 tb1 = tb1->jmp_next[n1];
... ... @@ -1274,8 +1274,8 @@ static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
1274 1274 ptb = &tb_next->jmp_first;
1275 1275 for(;;) {
1276 1276 tb1 = *ptb;
1277   - n1 = (long)tb1 & 3;
1278   - tb1 = (TranslationBlock *)((long)tb1 & ~3);
  1277 + n1 = (intptr_t)tb1 & 3;
  1278 + tb1 = (TranslationBlock *)((intptr_t)tb1 & ~3);
1279 1279 if (n1 == n && tb1 == tb)
1280 1280 break;
1281 1281 ptb = &tb1->jmp_next[n1];
... ... @@ -1843,7 +1843,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
1843 1843 int dirty_flags)
1844 1844 {
1845 1845 CPUState *env;
1846   - unsigned long length, start1;
  1846 + uintptr_t length, start1;
1847 1847 int i, mask, len;
1848 1848 uint8_t *p;
1849 1849  
... ... @@ -1873,10 +1873,10 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
1873 1873  
1874 1874 /* we modify the TLB cache so that the dirty bit will be set again
1875 1875 when accessing the range */
1876   - start1 = (unsigned long)qemu_get_ram_ptr(start);
  1876 + start1 = (uintptr_t)qemu_get_ram_ptr(start);
1877 1877 /* Chek that we don't span multiple blocks - this breaks the
1878 1878 address comparisons below. */
1879   - if ((unsigned long)qemu_get_ram_ptr(end - 1) - start1
  1879 + if ((uintptr_t)qemu_get_ram_ptr(end - 1) - start1
1880 1880 != (end - 1) - start) {
1881 1881 abort();
1882 1882 }
... ... @@ -1921,7 +1921,7 @@ static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
1921 1921 void *p;
1922 1922  
1923 1923 if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == IO_MEM_RAM) {
1924   - p = (void *)(unsigned long)((tlb_entry->addr_write & TARGET_PAGE_MASK)
  1924 + p = (void *)(uintptr_t)((tlb_entry->addr_write & TARGET_PAGE_MASK)
1925 1925 + tlb_entry->addend);
1926 1926 ram_addr = qemu_ram_addr_from_host(p);
1927 1927 if (!cpu_physical_memory_is_dirty(ram_addr)) {
... ... @@ -1996,7 +1996,7 @@ int tlb_set_page_exec(CPUState *env, target_ulong vaddr,
1996 1996 /* IO memory case (romd handled later) */
1997 1997 address |= TLB_MMIO;
1998 1998 }
1999   - addend = (unsigned long)qemu_get_ram_ptr(pd & TARGET_PAGE_MASK);
  1999 + addend = (uintptr_t)qemu_get_ram_ptr(pd & TARGET_PAGE_MASK);
2000 2000 if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) {
2001 2001 /* Normal RAM. */
2002 2002 iotlb = pd & TARGET_PAGE_MASK;
... ... @@ -3634,13 +3634,13 @@ void cpu_io_recompile(CPUState *env, void *retaddr)
3634 3634 target_ulong pc, cs_base;
3635 3635 uint64_t flags;
3636 3636  
3637   - tb = tb_find_pc((unsigned long)retaddr);
  3637 + tb = tb_find_pc((uintptr_t)retaddr);
3638 3638 if (!tb) {
3639 3639 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p",
3640 3640 retaddr);
3641 3641 }
3642 3642 n = env->icount_decr.u16.low + tb->icount;
3643   - cpu_restore_state(tb, env, (unsigned long)retaddr, NULL);
  3643 + cpu_restore_state(tb, env, (uintptr_t)retaddr, NULL);
3644 3644 /* Calculate how many instructions had been executed before the fault
3645 3645 occurred. */
3646 3646 n = n - env->icount_decr.u16.low;
... ...
gen-icount.h
... ... @@ -27,7 +27,7 @@ static void gen_icount_end(TranslationBlock *tb, int num_insns)
27 27 if (use_icount) {
28 28 *icount_arg = num_insns;
29 29 gen_set_label(icount_label);
30   - tcg_gen_exit_tb((long)tb + 2);
  30 + tcg_gen_exit_tb((intptr_t)tb + 2);
31 31 }
32 32 }
33 33  
... ...
hw/usb-ohci.c
... ... @@ -765,8 +765,9 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
765 765 }
766 766  
767 767 #ifdef DEBUG_ISOCH
768   - printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu ret %d\n",
769   - start_offset, end_offset, start_addr, end_addr, str, len, ret);
  768 + printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %" PRIuPTR
  769 + " ret %d\n", start_offset, end_offset, start_addr, end_addr, str,
  770 + len, ret);
770 771 #endif
771 772  
772 773 /* Writeback */
... ... @@ -783,7 +784,7 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
783 784 OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, 0);
784 785 } else {
785 786 if (ret > (ssize_t) len) {
786   - printf("usb-ohci: DataOverrun %d > %zu\n", ret, len);
  787 + printf("usb-ohci: DataOverrun %d > %" PRIuPTR "\n", ret, len);
787 788 OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
788 789 OHCI_CC_DATAOVERRUN);
789 790 OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
... ...
migration-tcp.c
... ... @@ -134,7 +134,7 @@ static void tcp_accept_incoming_migration(void *opaque)
134 134 {
135 135 struct sockaddr_in addr;
136 136 socklen_t addrlen = sizeof(addr);
137   - int s = (unsigned long)opaque;
  137 + int s = (intptr_t)opaque;
138 138 QEMUFile *f;
139 139 int c, ret;
140 140  
... ... @@ -200,7 +200,7 @@ int tcp_start_incoming_migration(const char *host_port)
200 200 goto err;
201 201  
202 202 qemu_set_fd_handler2(s, NULL, tcp_accept_incoming_migration, NULL,
203   - (void *)(unsigned long)s);
  203 + (void *)(intptr_t)s);
204 204  
205 205 return 0;
206 206  
... ...
monitor.c
... ... @@ -2740,9 +2740,9 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
2740 2740 }
2741 2741 if (nb_args + 3 > MAX_ARGS)
2742 2742 goto error_args;
2743   - args[nb_args++] = (void*)(long)count;
2744   - args[nb_args++] = (void*)(long)format;
2745   - args[nb_args++] = (void*)(long)size;
  2743 + args[nb_args++] = (void*)(intptr_t)count;
  2744 + args[nb_args++] = (void*)(intptr_t)format;
  2745 + args[nb_args++] = (void*)(intptr_t)size;
2746 2746 }
2747 2747 break;
2748 2748 case 'i':
... ... @@ -2771,7 +2771,7 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
2771 2771 typestr++;
2772 2772 if (nb_args >= MAX_ARGS)
2773 2773 goto error_args;
2774   - args[nb_args++] = (void *)(long)has_arg;
  2774 + args[nb_args++] = (void *)(intptr_t)has_arg;
2775 2775 if (!has_arg) {
2776 2776 if (nb_args >= MAX_ARGS)
2777 2777 goto error_args;
... ... @@ -2785,16 +2785,16 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
2785 2785 if (c == 'i') {
2786 2786 if (nb_args >= MAX_ARGS)
2787 2787 goto error_args;
2788   - args[nb_args++] = (void *)(long)val;
  2788 + args[nb_args++] = (void *)(intptr_t)val;
2789 2789 } else {
2790 2790 if ((nb_args + 1) >= MAX_ARGS)
2791 2791 goto error_args;
2792 2792 #if TARGET_PHYS_ADDR_BITS > 32
2793   - args[nb_args++] = (void *)(long)((val >> 32) & 0xffffffff);
  2793 + args[nb_args++] = (void *)(intptr_t)((val >> 32) & 0xffffffff);
2794 2794 #else
2795 2795 args[nb_args++] = (void *)0;
2796 2796 #endif
2797   - args[nb_args++] = (void *)(long)(val & 0xffffffff);
  2797 + args[nb_args++] = (void *)(intptr_t)(val & 0xffffffff);
2798 2798 }
2799 2799 }
2800 2800 break;
... ... @@ -2821,7 +2821,7 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
2821 2821 }
2822 2822 if (nb_args >= MAX_ARGS)
2823 2823 goto error_args;
2824   - args[nb_args++] = (void *)(long)has_option;
  2824 + args[nb_args++] = (void *)(intptr_t)has_option;
2825 2825 }
2826 2826 break;
2827 2827 default:
... ...
qemu-common.h
... ... @@ -64,10 +64,6 @@ static inline char *realpath(const char *path, char *resolved_path)
64 64 return resolved_path;
65 65 }
66 66  
67   -#define PRId64 "I64d"
68   -#define PRIx64 "I64x"
69   -#define PRIu64 "I64u"
70   -#define PRIo64 "I64o"
71 67 #endif
72 68  
73 69 /* FIXME: Remove NEED_CPU_H. */
... ...
slirp/cksum.c
... ... @@ -72,7 +72,7 @@ int cksum(struct mbuf *m, int len)
72 72 /*
73 73 * Force to even boundary.
74 74 */
75   - if ((1 & (long) w) && (mlen > 0)) {
  75 + if ((1 & (intptr_t) w) && (mlen > 0)) {
76 76 REDUCE;
77 77 sum <<= 8;
78 78 s_util.c[0] = *(u_int8_t *)w;
... ...
softmmu_header.h
... ... @@ -76,7 +76,7 @@ static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr)
76 76 int page_index;
77 77 RES_TYPE res;
78 78 target_ulong addr;
79   - unsigned long physaddr;
  79 + uintptr_t physaddr;
80 80 int mmu_idx;
81 81  
82 82 addr = ptr;
... ... @@ -87,7 +87,7 @@ static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr)
87 87 res = glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx);
88 88 } else {
89 89 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
90   - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)physaddr);
  90 + res = glue(glue(ld, USUFFIX), _raw)(physaddr);
91 91 }
92 92 return res;
93 93 }
... ... @@ -97,7 +97,7 @@ static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr)
97 97 {
98 98 int res, page_index;
99 99 target_ulong addr;
100   - unsigned long physaddr;
  100 + uintptr_t physaddr;
101 101 int mmu_idx;
102 102  
103 103 addr = ptr;
... ... @@ -108,7 +108,7 @@ static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr)
108 108 res = (DATA_STYPE)glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx);
109 109 } else {
110 110 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
111   - res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr);
  111 + res = glue(glue(lds, SUFFIX), _raw)(physaddr);
112 112 }
113 113 return res;
114 114 }
... ... @@ -122,7 +122,7 @@ static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE
122 122 {
123 123 int page_index;
124 124 target_ulong addr;
125   - unsigned long physaddr;
  125 + uintptr_t physaddr;
126 126 int mmu_idx;
127 127  
128 128 addr = ptr;
... ... @@ -133,7 +133,7 @@ static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE
133 133 glue(glue(__st, SUFFIX), MMUSUFFIX)(addr, v, mmu_idx);
134 134 } else {
135 135 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
136   - glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v);
  136 + glue(glue(st, SUFFIX), _raw)(physaddr, v);
137 137 }
138 138 }
139 139  
... ...
softmmu_template.h
... ... @@ -57,7 +57,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr,
57 57 int index;
58 58 index = (physaddr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
59 59 physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
60   - env->mem_io_pc = (unsigned long)retaddr;
  60 + env->mem_io_pc = (uintptr_t)retaddr;
61 61 if (index > (IO_MEM_NOTDIRTY >> IO_MEM_SHIFT)
62 62 && !can_do_io(env)) {
63 63 cpu_io_recompile(env, retaddr);
... ... @@ -122,7 +122,7 @@ DATA_TYPE REGPARM glue(glue(__ld, SUFFIX), MMUSUFFIX)(target_ulong addr,
122 122 }
123 123 #endif
124 124 addend = env->tlb_table[mmu_idx][index].addend;
125   - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)(addr+addend));
  125 + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t)(addr+addend));
126 126 }
127 127 } else {
128 128 /* the page is not in the TLB : fill it */
... ... @@ -177,7 +177,7 @@ static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(target_ulong addr,
177 177 } else {
178 178 /* unaligned/aligned access in the same page */
179 179 addend = env->tlb_table[mmu_idx][index].addend;
180   - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)(addr+addend));
  180 + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t)(addr+addend));
181 181 }
182 182 } else {
183 183 /* the page is not in the TLB : fill it */
... ... @@ -208,7 +208,7 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr,
208 208 }
209 209  
210 210 env->mem_io_vaddr = addr;
211   - env->mem_io_pc = (unsigned long)retaddr;
  211 + env->mem_io_pc = (uintptr_t)retaddr;
212 212 #if SHIFT <= 2
213 213 io_mem_write[index][SHIFT](io_mem_opaque[index], physaddr, val);
214 214 #else
... ... @@ -262,7 +262,7 @@ void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr,
262 262 }
263 263 #endif
264 264 addend = env->tlb_table[mmu_idx][index].addend;
265   - glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)(addr+addend), val);
  265 + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t)(addr+addend), val);
266 266 }
267 267 } else {
268 268 /* the page is not in the TLB : fill it */
... ... @@ -313,7 +313,7 @@ static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(target_ulong addr,
313 313 } else {
314 314 /* aligned/unaligned access in the same page */
315 315 addend = env->tlb_table[mmu_idx][index].addend;
316   - glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)(addr+addend), val);
  316 + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t)(addr+addend), val);
317 317 }
318 318 } else {
319 319 /* the page is not in the TLB : fill it */
... ...
sysemu.h
... ... @@ -21,7 +21,7 @@ extern int vm_running;
21 21 extern const char *qemu_name;
22 22 extern uint8_t qemu_uuid[];
23 23 int qemu_uuid_parse(const char *str, uint8_t *uuid);
24   -#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
  24 +#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
25 25  
26 26 typedef struct vm_change_state_entry VMChangeStateEntry;
27 27 typedef void VMChangeStateHandler(void *opaque, int running, int reason);
... ...
target-alpha/op_helper.c
... ... @@ -1170,7 +1170,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
1170 1170 {
1171 1171 TranslationBlock *tb;
1172 1172 CPUState *saved_env;
1173   - unsigned long pc;
  1173 + uintptr_t pc;
1174 1174 int ret;
1175 1175  
1176 1176 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -1181,7 +1181,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
1181 1181 if (!likely(ret == 0)) {
1182 1182 if (likely(retaddr)) {
1183 1183 /* now we have a real cpu fault */
1184   - pc = (unsigned long)retaddr;
  1184 + pc = (uintptr_t)retaddr;
1185 1185 tb = tb_find_pc(pc);
1186 1186 if (likely(tb)) {
1187 1187 /* the PC is inside the translated code. It means that we have
... ...
target-alpha/translate.c
... ... @@ -2509,7 +2509,7 @@ CPUAlphaState * cpu_alpha_init (const char *cpu_model)
2509 2509 }
2510 2510  
2511 2511 void gen_pc_load(CPUState *env, TranslationBlock *tb,
2512   - unsigned long searched_pc, int pc_pos, void *puc)
  2512 + uintptr_t searched_pc, int pc_pos, void *puc)
2513 2513 {
2514 2514 env->pc = gen_opc_pc[pc_pos];
2515 2515 }
... ...
target-arm/op_helper.c
... ... @@ -88,7 +88,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
88 88 {
89 89 TranslationBlock *tb;
90 90 CPUState *saved_env;
91   - unsigned long pc;
  91 + uintptr_t pc;
92 92 int ret;
93 93  
94 94 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -99,7 +99,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
99 99 if (unlikely(ret)) {
100 100 if (retaddr) {
101 101 /* now we have a real cpu fault */
102   - pc = (unsigned long)retaddr;
  102 + pc = (uintptr_t)retaddr;
103 103 tb = tb_find_pc(pc);
104 104 if (tb) {
105 105 /* the PC is inside the translated code. It means that we have
... ...
target-arm/translate.c
... ... @@ -3198,7 +3198,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint32_t dest)
3198 3198 if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
3199 3199 tcg_gen_goto_tb(n);
3200 3200 gen_set_pc_im(dest);
3201   - tcg_gen_exit_tb((long)tb + n);
  3201 + tcg_gen_exit_tb((intptr_t)tb + n);
3202 3202 } else {
3203 3203 gen_set_pc_im(dest);
3204 3204 tcg_gen_exit_tb(0);
... ... @@ -9027,7 +9027,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
9027 9027 }
9028 9028  
9029 9029 void gen_pc_load(CPUState *env, TranslationBlock *tb,
9030   - unsigned long searched_pc, int pc_pos, void *puc)
  9030 + uintptr_t searched_pc, int pc_pos, void *puc)
9031 9031 {
9032 9032 env->regs[15] = gen_opc_pc[pc_pos];
9033 9033 }
... ...
target-cris/op_helper.c
... ... @@ -58,7 +58,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
58 58 {
59 59 TranslationBlock *tb;
60 60 CPUState *saved_env;
61   - unsigned long pc;
  61 + uintptr_t pc;
62 62 int ret;
63 63  
64 64 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -72,7 +72,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
72 72 if (unlikely(ret)) {
73 73 if (retaddr) {
74 74 /* now we have a real cpu fault */
75   - pc = (unsigned long)retaddr;
  75 + pc = (uintptr_t)retaddr;
76 76 tb = tb_find_pc(pc);
77 77 if (tb) {
78 78 /* the PC is inside the translated code. It means that we have
... ...
target-cris/translate.c
... ... @@ -523,7 +523,7 @@ static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest)
523 523 if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
524 524 tcg_gen_goto_tb(n);
525 525 tcg_gen_movi_tl(env_pc, dest);
526   - tcg_gen_exit_tb((long)tb + n);
  526 + tcg_gen_exit_tb((intptr_t)tb + n);
527 527 } else {
528 528 tcg_gen_movi_tl(env_pc, dest);
529 529 tcg_gen_exit_tb(0);
... ... @@ -3478,7 +3478,7 @@ void cpu_reset (CPUCRISState *env)
3478 3478 }
3479 3479  
3480 3480 void gen_pc_load(CPUState *env, struct TranslationBlock *tb,
3481   - unsigned long searched_pc, int pc_pos, void *puc)
  3481 + uintptr_t searched_pc, int pc_pos, void *puc)
3482 3482 {
3483 3483 env->pc = gen_opc_pc[pc_pos];
3484 3484 }
... ...
target-i386/op_helper.c
... ... @@ -4830,7 +4830,7 @@ void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
4830 4830 {
4831 4831 TranslationBlock *tb;
4832 4832 int ret;
4833   - unsigned long pc;
  4833 + uintptr_t pc;
4834 4834 CPUX86State *saved_env;
4835 4835  
4836 4836 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -4842,7 +4842,7 @@ void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
4842 4842 if (ret) {
4843 4843 if (retaddr) {
4844 4844 /* now we have a real cpu fault */
4845   - pc = (unsigned long)retaddr;
  4845 + pc = (uintptr_t)retaddr;
4846 4846 tb = tb_find_pc(pc);
4847 4847 if (tb) {
4848 4848 /* the PC is inside the translated code. It means that we have
... ...
target-i386/translate.c
... ... @@ -2293,7 +2293,7 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num, target_ulong eip)
2293 2293 /* jump to same page: we can use a direct jump */
2294 2294 tcg_gen_goto_tb(tb_num);
2295 2295 gen_jmp_im(eip);
2296   - tcg_gen_exit_tb((long)tb + tb_num);
  2296 + tcg_gen_exit_tb((intptr_t)tb + tb_num);
2297 2297 } else {
2298 2298 /* jump to another page: currently not optimized */
2299 2299 gen_jmp_im(eip);
... ... @@ -7787,7 +7787,7 @@ void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
7787 7787 }
7788 7788  
7789 7789 void gen_pc_load(CPUState *env, TranslationBlock *tb,
7790   - unsigned long searched_pc, int pc_pos, void *puc)
  7790 + uintptr_t searched_pc, int pc_pos, void *puc)
7791 7791 {
7792 7792 int cc_op;
7793 7793 #ifdef DEBUG_DISAS
... ... @@ -7799,7 +7799,7 @@ void gen_pc_load(CPUState *env, TranslationBlock *tb,
7799 7799 qemu_log("0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
7800 7800 }
7801 7801 }
7802   - qemu_log("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
  7802 + qemu_log("spc=0x%08Ix pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
7803 7803 searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base,
7804 7804 (uint32_t)tb->cs_base);
7805 7805 }
... ...
target-m68k/op_helper.c
... ... @@ -52,7 +52,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
52 52 {
53 53 TranslationBlock *tb;
54 54 CPUState *saved_env;
55   - unsigned long pc;
  55 + uintptr_t pc;
56 56 int ret;
57 57  
58 58 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -63,7 +63,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
63 63 if (unlikely(ret)) {
64 64 if (retaddr) {
65 65 /* now we have a real cpu fault */
66   - pc = (unsigned long)retaddr;
  66 + pc = (uintptr_t)retaddr;
67 67 tb = tb_find_pc(pc);
68 68 if (tb) {
69 69 /* the PC is inside the translated code. It means that we have
... ...
target-m68k/translate.c
... ... @@ -862,7 +862,7 @@ static void gen_jmp_tb(DisasContext *s, int n, uint32_t dest)
862 862 (s->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
863 863 tcg_gen_goto_tb(n);
864 864 tcg_gen_movi_i32(QREG_PC, dest);
865   - tcg_gen_exit_tb((long)tb + n);
  865 + tcg_gen_exit_tb((intptr_t)tb + n);
866 866 } else {
867 867 gen_jmp_im(s, dest);
868 868 tcg_gen_exit_tb(0);
... ... @@ -3118,7 +3118,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
3118 3118 }
3119 3119  
3120 3120 void gen_pc_load(CPUState *env, TranslationBlock *tb,
3121   - unsigned long searched_pc, int pc_pos, void *puc)
  3121 + uintptr_t searched_pc, int pc_pos, void *puc)
3122 3122 {
3123 3123 env->pc = gen_opc_pc[pc_pos];
3124 3124 }
... ...
target-microblaze/op_helper.c
... ... @@ -43,7 +43,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
43 43 {
44 44 TranslationBlock *tb;
45 45 CPUState *saved_env;
46   - unsigned long pc;
  46 + uintptr_t pc;
47 47 int ret;
48 48  
49 49 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -55,7 +55,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
55 55 if (unlikely(ret)) {
56 56 if (retaddr) {
57 57 /* now we have a real cpu fault */
58   - pc = (unsigned long)retaddr;
  58 + pc = (uintptr_t)retaddr;
59 59 tb = tb_find_pc(pc);
60 60 if (tb) {
61 61 /* the PC is inside the translated code. It means that we have
... ...
target-microblaze/translate.c
... ... @@ -146,7 +146,7 @@ static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest)
146 146 if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
147 147 tcg_gen_goto_tb(n);
148 148 tcg_gen_movi_tl(cpu_SR[SR_PC], dest);
149   - tcg_gen_exit_tb((long)tb + n);
  149 + tcg_gen_exit_tb((intptr_t)tb + n);
150 150 } else {
151 151 tcg_gen_movi_tl(cpu_SR[SR_PC], dest);
152 152 tcg_gen_exit_tb(0);
... ... @@ -1388,7 +1388,7 @@ void cpu_reset (CPUState *env)
1388 1388 }
1389 1389  
1390 1390 void gen_pc_load(CPUState *env, struct TranslationBlock *tb,
1391   - unsigned long searched_pc, int pc_pos, void *puc)
  1391 + uintptr_t searched_pc, int pc_pos, void *puc)
1392 1392 {
1393 1393 env->sregs[SR_PC] = gen_opc_pc[pc_pos];
1394 1394 }
... ...
target-mips/op_helper.c
... ... @@ -1822,7 +1822,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
1822 1822 {
1823 1823 TranslationBlock *tb;
1824 1824 CPUState *saved_env;
1825   - unsigned long pc;
  1825 + uintptr_t pc;
1826 1826 int ret;
1827 1827  
1828 1828 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -1833,7 +1833,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
1833 1833 if (ret) {
1834 1834 if (retaddr) {
1835 1835 /* now we have a real cpu fault */
1836   - pc = (unsigned long)retaddr;
  1836 + pc = (uintptr_t)retaddr;
1837 1837 tb = tb_find_pc(pc);
1838 1838 if (tb) {
1839 1839 /* the PC is inside the translated code. It means that we have
... ...
target-mips/translate.c
... ... @@ -2462,7 +2462,7 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
2462 2462 if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
2463 2463 tcg_gen_goto_tb(n);
2464 2464 gen_save_pc(dest);
2465   - tcg_gen_exit_tb((long)tb + n);
  2465 + tcg_gen_exit_tb((intptr_t)tb + n);
2466 2466 } else {
2467 2467 gen_save_pc(dest);
2468 2468 tcg_gen_exit_tb(0);
... ... @@ -8640,7 +8640,7 @@ void cpu_reset (CPUMIPSState *env)
8640 8640 }
8641 8641  
8642 8642 void gen_pc_load(CPUState *env, TranslationBlock *tb,
8643   - unsigned long searched_pc, int pc_pos, void *puc)
  8643 + uintptr_t searched_pc, int pc_pos, void *puc)
8644 8644 {
8645 8645 env->active_tc.PC = gen_opc_pc[pc_pos];
8646 8646 env->hflags &= ~MIPS_HFLAG_BMASK;
... ...
target-ppc/op_helper.c
... ... @@ -3714,7 +3714,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
3714 3714 {
3715 3715 TranslationBlock *tb;
3716 3716 CPUState *saved_env;
3717   - unsigned long pc;
  3717 + uintptr_t pc;
3718 3718 int ret;
3719 3719  
3720 3720 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -3725,7 +3725,7 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
3725 3725 if (unlikely(ret != 0)) {
3726 3726 if (likely(retaddr)) {
3727 3727 /* now we have a real cpu fault */
3728   - pc = (unsigned long)retaddr;
  3728 + pc = (uintptr_t)retaddr;
3729 3729 tb = tb_find_pc(pc);
3730 3730 if (likely(tb)) {
3731 3731 /* the PC is inside the translated code. It means that we have
... ...
target-ppc/translate.c
... ... @@ -3298,7 +3298,7 @@ static always_inline void gen_goto_tb (DisasContext *ctx, int n,
3298 3298 likely(!ctx->singlestep_enabled)) {
3299 3299 tcg_gen_goto_tb(n);
3300 3300 tcg_gen_movi_tl(cpu_nip, dest & ~3);
3301   - tcg_gen_exit_tb((long)tb + n);
  3301 + tcg_gen_exit_tb((intptr_t)tb + n);
3302 3302 } else {
3303 3303 tcg_gen_movi_tl(cpu_nip, dest & ~3);
3304 3304 if (unlikely(ctx->singlestep_enabled)) {
... ... @@ -9098,7 +9098,7 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
9098 9098 }
9099 9099  
9100 9100 void gen_pc_load(CPUState *env, TranslationBlock *tb,
9101   - unsigned long searched_pc, int pc_pos, void *puc)
  9101 + uintptr_t searched_pc, int pc_pos, void *puc)
9102 9102 {
9103 9103 env->nip = gen_opc_pc[pc_pos];
9104 9104 }
... ...
target-sh4/op_helper.c
... ... @@ -41,7 +41,7 @@ void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
41 41 {
42 42 TranslationBlock *tb;
43 43 CPUState *saved_env;
44   - unsigned long pc;
  44 + uintptr_t pc;
45 45 int ret;
46 46  
47 47 /* XXX: hack to restore env in all cases, even if not called from
... ... @@ -52,7 +52,7 @@ void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
52 52 if (ret) {
53 53 if (retaddr) {
54 54 /* now we have a real cpu fault */
55   - pc = (unsigned long) retaddr;
  55 + pc = (uintptr_t) retaddr;
56 56 tb = tb_find_pc(pc);
57 57 if (tb) {
58 58 /* the PC is inside the translated code. It means that we have
... ...
target-sh4/translate.c
... ... @@ -302,7 +302,7 @@ static void gen_goto_tb(DisasContext * ctx, int n, target_ulong dest)
302 302 /* Use a direct jump if in same page and singlestep not enabled */
303 303 tcg_gen_goto_tb(n);
304 304 tcg_gen_movi_i32(cpu_pc, dest);
305   - tcg_gen_exit_tb((long) tb + n);
  305 + tcg_gen_exit_tb((intptr_t) tb + n);
306 306 } else {
307 307 tcg_gen_movi_i32(cpu_pc, dest);
308 308 if (ctx->singlestep_enabled)
... ... @@ -2030,7 +2030,7 @@ void gen_intermediate_code_pc(CPUState * env, struct TranslationBlock *tb)
2030 2030 }
2031 2031  
2032 2032 void gen_pc_load(CPUState *env, TranslationBlock *tb,
2033   - unsigned long searched_pc, int pc_pos, void *puc)
  2033 + uintptr_t searched_pc, int pc_pos, void *puc)
2034 2034 {
2035 2035 env->pc = gen_opc_pc[pc_pos];
2036 2036 env->flags = gen_opc_hflags[pc_pos];
... ...
target-sparc/translate.c
... ... @@ -236,7 +236,7 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num,
236 236 tcg_gen_goto_tb(tb_num);
237 237 tcg_gen_movi_tl(cpu_pc, pc);
238 238 tcg_gen_movi_tl(cpu_npc, npc);
239   - tcg_gen_exit_tb((long)tb + tb_num);
  239 + tcg_gen_exit_tb((intptr_t)tb + tb_num);
240 240 } else {
241 241 /* jump to another page: currently not optimized */
242 242 tcg_gen_movi_tl(cpu_pc, pc);
... ... @@ -4891,7 +4891,7 @@ void gen_intermediate_code_init(CPUSPARCState *env)
4891 4891 }
4892 4892  
4893 4893 void gen_pc_load(CPUState *env, TranslationBlock *tb,
4894   - unsigned long searched_pc, int pc_pos, void *puc)
  4894 + uintptr_t searched_pc, int pc_pos, void *puc)
4895 4895 {
4896 4896 target_ulong npc;
4897 4897 env->pc = gen_opc_pc[pc_pos];
... ...
tcg/arm/tcg-target.h
... ... @@ -69,7 +69,7 @@ enum {
69 69 TCG_AREG0 = TCG_REG_R7,
70 70 };
71 71  
72   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  72 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
73 73 {
74 74 #if QEMU_GNUC_PREREQ(4, 1)
75 75 __builtin___clear_cache((char *) start, (char *) stop);
... ...
tcg/hppa/tcg-target.h
... ... @@ -83,7 +83,7 @@ enum {
83 83 /* Note: must be synced with dyngen-exec.h */
84 84 #define TCG_AREG0 TCG_REG_R17
85 85  
86   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  86 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
87 87 {
88 88 start &= ~31;
89 89 while (start <= stop)
... ...
tcg/i386/tcg-target.h
... ... @@ -58,6 +58,6 @@ enum {
58 58 /* Note: must be synced with dyngen-exec.h */
59 59 #define TCG_AREG0 TCG_REG_EBP
60 60  
61   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  61 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
62 62 {
63 63 }
... ...
tcg/ppc/tcg-target.c
... ... @@ -1120,11 +1120,11 @@ static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args,
1120 1120 tcg_out_bc (s, (BC | BI (7, CR_EQ) | BO_COND_TRUE), label_index);
1121 1121 }
1122 1122  
1123   -void ppc_tb_set_jmp_target (unsigned long jmp_addr, unsigned long addr)
  1123 +void ppc_tb_set_jmp_target (uintptr_t jmp_addr, uintptr_t addr)
1124 1124 {
1125 1125 uint32_t *ptr;
1126   - long disp = addr - jmp_addr;
1127   - unsigned long patch_size;
  1126 + intptr_t disp = addr - jmp_addr;
  1127 + uintptr_t patch_size;
1128 1128  
1129 1129 ptr = (uint32_t *)jmp_addr;
1130 1130  
... ...
tcg/sparc/tcg-target.h
... ... @@ -103,7 +103,7 @@ enum {
103 103 #define TCG_AREG0 TCG_REG_G6
104 104 #endif
105 105  
106   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  106 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
107 107 {
108 108 unsigned long p;
109 109  
... ...
tcg/tcg.c
... ... @@ -244,8 +244,8 @@ void tcg_context_init(TCGContext *s)
244 244 s->code_buf = code_gen_prologue;
245 245 s->code_ptr = s->code_buf;
246 246 tcg_target_qemu_prologue(s);
247   - flush_icache_range((unsigned long)s->code_buf,
248   - (unsigned long)s->code_ptr);
  247 + flush_icache_range((uintptr_t)s->code_buf,
  248 + (uintptr_t)s->code_ptr);
249 249 }
250 250  
251 251 void tcg_set_frame(TCGContext *s, int reg,
... ... @@ -2153,7 +2153,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
2153 2153 break;
2154 2154 case INDEX_op_set_label:
2155 2155 tcg_reg_alloc_bb_end(s, s->reserved_regs);
2156   - tcg_out_label(s, args[0], (long)s->code_ptr);
  2156 + tcg_out_label(s, args[0], (intptr_t)s->code_ptr);
2157 2157 break;
2158 2158 case INDEX_op_call:
2159 2159 dead_iargs = s->op_dead_iargs[op_index];
... ... @@ -2202,8 +2202,8 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
2202 2202 tcg_gen_code_common(s, gen_code_buf, -1);
2203 2203  
2204 2204 /* flush instruction cache */
2205   - flush_icache_range((unsigned long)gen_code_buf,
2206   - (unsigned long)s->code_ptr);
  2205 + flush_icache_range((uintptr_t)gen_code_buf,
  2206 + (uintptr_t)s->code_ptr);
2207 2207 return s->code_ptr - gen_code_buf;
2208 2208 }
2209 2209  
... ...
tcg/tcg.h
... ... @@ -468,7 +468,7 @@ uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2);
468 468 extern uint8_t code_gen_prologue[];
469 469 #if defined(_ARCH_PPC) && !defined(_ARCH_PPC64)
470 470 #define tcg_qemu_tb_exec(tb_ptr) \
471   - ((long REGPARM __attribute__ ((longcall)) (*)(void *))code_gen_prologue)(tb_ptr)
  471 + ((intptr_t REGPARM __attribute__ ((longcall)) (*)(void *))code_gen_prologue)(tb_ptr)
472 472 #else
473   -#define tcg_qemu_tb_exec(tb_ptr) ((long REGPARM (*)(void *))code_gen_prologue)(tb_ptr)
  473 +#define tcg_qemu_tb_exec(tb_ptr) ((intptr_t REGPARM (*)(void *))code_gen_prologue)(tb_ptr)
474 474 #endif
... ...
tcg/x86_64/tcg-target.c
... ... @@ -62,12 +62,19 @@ static const int tcg_target_reg_alloc_order[] = {
62 62 };
63 63  
64 64 static const int tcg_target_call_iarg_regs[6] = {
  65 +#ifdef _WIN64
  66 + TCG_REG_RCX,
  67 + TCG_REG_RDX,
  68 + TCG_REG_R8,
  69 + TCG_REG_R9,
  70 +#else
65 71 TCG_REG_RDI,
66 72 TCG_REG_RSI,
67 73 TCG_REG_RDX,
68 74 TCG_REG_RCX,
69 75 TCG_REG_R8,
70 76 TCG_REG_R9,
  77 +#endif
71 78 };
72 79  
73 80 static const int tcg_target_call_oarg_regs[2] = {
... ... @@ -93,7 +100,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
93 100 *(uint32_t *)code_ptr = value;
94 101 break;
95 102 case R_386_PC32:
96   - value -= (long)code_ptr;
  103 + value -= (intptr_t)code_ptr;
97 104 if (value != (int32_t)value)
98 105 tcg_abort();
99 106 *(uint32_t *)code_ptr = value;
... ... @@ -151,8 +158,8 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
151 158 case 'L': /* qemu_ld/st constraint */
152 159 ct->ct |= TCG_CT_REG;
153 160 tcg_regset_set32(ct->u.regs, 0, 0xffff);
154   - tcg_regset_reset_reg(ct->u.regs, TCG_REG_RSI);
155   - tcg_regset_reset_reg(ct->u.regs, TCG_REG_RDI);
  161 + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[0]);
  162 + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[1]);
156 163 break;
157 164 case 'e':
158 165 ct->ct |= TCG_CT_CONST_S32;
... ... @@ -518,8 +525,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
518 525 mem_index = *args;
519 526 s_bits = opc & 3;
520 527  
521   - r0 = TCG_REG_RDI;
522   - r1 = TCG_REG_RSI;
  528 + r0 = tcg_target_call_iarg_regs[0];
  529 + r1 = tcg_target_call_iarg_regs[1];
523 530  
524 531 #if TARGET_LONG_BITS == 32
525 532 rexw = 0;
... ... @@ -558,7 +565,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
558 565 s->code_ptr++;
559 566  
560 567 /* XXX: move that code at the end of the TB */
561   - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RSI, mem_index);
  568 + tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1], mem_index);
562 569 tcg_out8(s, 0xe8);
563 570 tcg_out32(s, (tcg_target_long)qemu_ld_helpers[s_bits] -
564 571 (tcg_target_long)s->code_ptr - 4);
... ... @@ -715,8 +722,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
715 722  
716 723 s_bits = opc;
717 724  
718   - r0 = TCG_REG_RDI;
719   - r1 = TCG_REG_RSI;
  725 + r0 = tcg_target_call_iarg_regs[0];
  726 + r1 = tcg_target_call_iarg_regs[1];
720 727  
721 728 #if TARGET_LONG_BITS == 32
722 729 rexw = 0;
... ... @@ -758,22 +765,22 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
758 765 switch(opc) {
759 766 case 0:
760 767 /* movzbl */
761   - tcg_out_modrm(s, 0xb6 | P_EXT | P_REXB, TCG_REG_RSI, data_reg);
  768 + tcg_out_modrm(s, 0xb6 | P_EXT | P_REXB, r1, data_reg);
762 769 break;
763 770 case 1:
764 771 /* movzwl */
765   - tcg_out_modrm(s, 0xb7 | P_EXT, TCG_REG_RSI, data_reg);
  772 + tcg_out_modrm(s, 0xb7 | P_EXT, r1, data_reg);
766 773 break;
767 774 case 2:
768 775 /* movl */
769   - tcg_out_modrm(s, 0x8b, TCG_REG_RSI, data_reg);
  776 + tcg_out_modrm(s, 0x8b, r1, data_reg);
770 777 break;
771 778 default:
772 779 case 3:
773   - tcg_out_mov(s, TCG_REG_RSI, data_reg);
  780 + tcg_out_mov(s, TCG_REG_RDX, data_reg);
774 781 break;
775 782 }
776   - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RDX, mem_index);
  783 + tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2], mem_index);
777 784 tcg_out8(s, 0xe8);
778 785 tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] -
779 786 (tcg_target_long)s->code_ptr - 4);
... ... @@ -1211,6 +1218,10 @@ static int tcg_target_callee_save_regs[] = {
1211 1218 /* TCG_REG_R14, */ /* currently used for the global env, so no
1212 1219 need to save */
1213 1220 TCG_REG_R15,
  1221 +#ifdef _WIN64
  1222 + TCG_REG_RDI,
  1223 + TCG_REG_RSI,
  1224 +#endif
1214 1225 };
1215 1226  
1216 1227 static inline void tcg_out_push(TCGContext *s, int reg)
... ... @@ -1242,7 +1253,7 @@ void tcg_target_qemu_prologue(TCGContext *s)
1242 1253 stack_addend = frame_size - push_size;
1243 1254 tcg_out_addi(s, TCG_REG_RSP, -stack_addend);
1244 1255  
1245   - tcg_out_modrm(s, 0xff, 4, TCG_REG_RDI); /* jmp *%rdi */
  1256 + tcg_out_modrm(s, 0xff, 4, tcg_target_call_iarg_regs[0]); /* jmp *%rdi */
1246 1257  
1247 1258 /* TB epilogue */
1248 1259 tb_ret_addr = s->code_ptr;
... ... @@ -1362,8 +1373,10 @@ void tcg_target_init(TCGContext *s)
1362 1373 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
1363 1374 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffff);
1364 1375 tcg_regset_set32(tcg_target_call_clobber_regs, 0,
1365   - (1 << TCG_REG_RDI) |
1366   - (1 << TCG_REG_RSI) |
  1376 +#ifndef _WIN64
  1377 + (1 << TCG_REG_RDI) |
  1378 + (1 << TCG_REG_RSI) |
  1379 +#endif
1367 1380 (1 << TCG_REG_RDX) |
1368 1381 (1 << TCG_REG_RCX) |
1369 1382 (1 << TCG_REG_R8) |
... ...
tcg/x86_64/tcg-target.h
... ... @@ -78,6 +78,6 @@ enum {
78 78 /* Note: must be synced with dyngen-exec.h */
79 79 #define TCG_AREG0 TCG_REG_R14
80 80  
81   -static inline void flush_icache_range(unsigned long start, unsigned long stop)
  81 +static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
82 82 {
83 83 }
... ...
translate-all.c
... ... @@ -49,9 +49,9 @@ uint32_t gen_opc_hflags[OPC_BUF_SIZE];
49 49 #endif
50 50  
51 51 /* XXX: suppress that */
52   -unsigned long code_gen_max_block_size(void)
  52 +uintptr_t code_gen_max_block_size(void)
53 53 {
54   - static unsigned long max;
  54 + static uintptr_t max;
55 55  
56 56 if (max == 0) {
57 57 max = TCG_MAX_OP_SIZE;
... ... @@ -135,12 +135,12 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
135 135 /* The cpu state corresponding to 'searched_pc' is restored.
136 136 */
137 137 int cpu_restore_state(TranslationBlock *tb,
138   - CPUState *env, unsigned long searched_pc,
  138 + CPUState *env, uintptr_t searched_pc,
139 139 void *puc)
140 140 {
141 141 TCGContext *s = &tcg_ctx;
142 142 int j;
143   - unsigned long tc_ptr;
  143 + uintptr_t tc_ptr;
144 144 #ifdef CONFIG_PROFILER
145 145 int64_t ti;
146 146 #endif
... ... @@ -160,7 +160,7 @@ int cpu_restore_state(TranslationBlock *tb,
160 160 }
161 161  
162 162 /* find opc index corresponding to search_pc */
163   - tc_ptr = (unsigned long)tb->tc_ptr;
  163 + tc_ptr = (uintptr_t)tb->tc_ptr;
164 164 if (searched_pc < tc_ptr)
165 165 return -1;
166 166  
... ...
... ... @@ -1455,7 +1455,7 @@ static int win32_start_timer(struct qemu_alarm_timer *t)
1455 1455 data->timerId = timeSetEvent(1, // interval (ms)
1456 1456 data->period, // resolution
1457 1457 host_alarm_handler, // function
1458   - (DWORD)t, // parameter
  1458 + (DWORD_PTR)t, // parameter
1459 1459 flags);
1460 1460  
1461 1461 if (!data->timerId) {
... ... @@ -1492,7 +1492,7 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
1492 1492 data->timerId = timeSetEvent(1,
1493 1493 data->period,
1494 1494 host_alarm_handler,
1495   - (DWORD)t,
  1495 + (DWORD_PTR)t,
1496 1496 TIME_ONESHOT | TIME_PERIODIC);
1497 1497  
1498 1498 if (!data->timerId) {
... ... @@ -4607,17 +4607,38 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
4607 4607  
4608 4608 int qemu_uuid_parse(const char *str, uint8_t *uuid)
4609 4609 {
4610   - int ret;
  4610 + int pos = 0;
  4611 + uint8_t *uuid_ptr = uuid;
4611 4612  
4612   - if(strlen(str) != 36)
  4613 + if(strlen(str) != 36) {
4613 4614 return -1;
  4615 + }
4614 4616  
4615   - ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
4616   - &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
4617   - &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15]);
4618   -
4619   - if(ret != 16)
4620   - return -1;
  4617 + while (pos < 36) {
  4618 + if (pos == 8 || pos == 13 || pos == 18 || pos == 23) {
  4619 + if (str[pos] != '-') {
  4620 + return -1;
  4621 + }
  4622 + pos++;
  4623 + } else {
  4624 + if (str[pos] >= '0' && str[pos] <= '9') {
  4625 + *uuid_ptr = (str[pos] - '0') << 4;
  4626 + } else if (str[pos] >= 'a' && str[pos] <= 'f') {
  4627 + *uuid_ptr = (str[pos] - 'a' + 0xa) << 4;
  4628 + } else if (str[pos] >= 'A' && str[pos] <= 'F') {
  4629 + *uuid_ptr = (str[pos] - 'A' + 0xa) << 4;
  4630 + }
  4631 + pos++;
  4632 + if (str[pos] >= '0' && str[pos] <= '9') {
  4633 + *uuid_ptr += str[pos] - '0';
  4634 + } else if (str[pos] >= 'a' && str[pos] <= 'f') {
  4635 + *uuid_ptr += str[pos] - 'a' + 0xa;
  4636 + } else if (str[pos] >= 'A' && str[pos] <= 'F') {
  4637 + *uuid_ptr += str[pos] - 'A' + 0xa;
  4638 + }
  4639 + pos++;
  4640 + }
  4641 + }
4621 4642  
4622 4643 #ifdef TARGET_I386
4623 4644 smbios_add_field(1, offsetof(struct smbios_type_1, uuid), 16, uuid);
... ... @@ -4887,7 +4908,7 @@ int main(int argc, char **argv, char **envp)
4887 4908 QEMU to run on a single CPU */
4888 4909 {
4889 4910 HANDLE h;
4890   - DWORD mask, smask;
  4911 + DWORD_PTR mask, smask;
4891 4912 int i;
4892 4913 h = GetCurrentProcess();
4893 4914 if (GetProcessAffinityMask(h, &mask, &smask)) {
... ...