From 3795016a825c2c2eceacbba2457033d84c59405f Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Wed, 9 Aug 2023 07:37:45 -0400 Subject: [PATCH 1/4] Clean up some clang warnings on macOS --- src/86box.c | 8 ++++++-- src/cpu/386_dynarec.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/86box.c b/src/86box.c index 8f71b9ffa..d129de4d0 100644 --- a/src/86box.c +++ b/src/86box.c @@ -918,11 +918,15 @@ pc_init_modules(void) #ifdef USE_DYNAREC # if defined(__APPLE__) && defined(__aarch64__) - pthread_jit_write_protect_np(0); + if (__builtin_available(macOS 11.0, *)) { + pthread_jit_write_protect_np(0); + } # endif codegen_init(); # if defined(__APPLE__) && defined(__aarch64__) - pthread_jit_write_protect_np(1); + if (__builtin_available(macOS 11.0, *)) { + pthread_jit_write_protect_np(1); + } # endif #endif diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 1d271db29..21eb7c2b7 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -484,7 +484,9 @@ exec386_dynarec_dyn(void) x86_was_reset = 0; # if defined(__APPLE__) && defined(__aarch64__) - pthread_jit_write_protect_np(0); + if (__builtin_available(macOS 11.0, *)) { + pthread_jit_write_protect_np(0); + } # endif codegen_block_start_recompile(block); codegen_in_recompile = 1; @@ -568,7 +570,9 @@ exec386_dynarec_dyn(void) codegen_in_recompile = 0; # if defined(__APPLE__) && defined(__aarch64__) - pthread_jit_write_protect_np(1); + if (__builtin_available(macOS 11.0, *)) { + pthread_jit_write_protect_np(1); + } # endif } else if (!cpu_state.abrt) { /* Mark block but do not recompile */ From cb28daba98c6cdf9e3523755eba39717e4e26186 Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Wed, 9 Aug 2023 07:43:48 -0400 Subject: [PATCH 2/4] Match the destination register type on apple silicon. Clears up a clang warning. --- src/cpu/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index ecfb438da..6c01f2469 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -394,8 +394,13 @@ typedef struct { MMX_REG MM[8]; #ifdef USE_NEW_DYNAREC +# if defined(__APPLE__) && defined(__aarch64__) + uint64_t old_fp_control; + uint64_t new_fp_control; +# else uint32_t old_fp_control; uint32_t new_fp_control; +# endif # if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 uint16_t old_fp_control2; uint16_t new_fp_control2; From f40184d43f0bf8a0ed64f0a6d14f140b2d5551eb Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Wed, 9 Aug 2023 07:48:12 -0400 Subject: [PATCH 3/4] Clear up a clang warning by correcting a format string --- src/codegen_new/codegen_backend_arm64_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_new/codegen_backend_arm64_ops.c b/src/codegen_new/codegen_backend_arm64_ops.c index 5667d2c93..594a5d524 100644 --- a/src/codegen_new/codegen_backend_arm64_ops.c +++ b/src/codegen_new/codegen_backend_arm64_ops.c @@ -684,7 +684,7 @@ host_arm64_CMPX_IMM(codeblock_t *block, int src_n_reg, uint64_t imm_data) } else if (!(imm_data & 0xfffffffffffff000ull)) { codegen_addlong(block, OPCODE_CMPX_IMM | Rd(REG_XZR) | Rn(src_n_reg) | IMM12(imm_data & 0xfff) | DATPROC_IMM_SHIFT(0)); } else - fatal("CMPX_IMM %08x\n", imm_data); + fatal("CMPX_IMM %08llx\n", imm_data); } void From 538e402193647c27db88856397623baf98e5d049 Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Wed, 9 Aug 2023 09:56:06 -0400 Subject: [PATCH 4/4] Fixed warning around formatting string for size_t --- src/cpu/808x/queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/808x/queue.c b/src/cpu/808x/queue.c index 0edf4e47a..34882e124 100644 --- a/src/cpu/808x/queue.c +++ b/src/cpu/808x/queue.c @@ -78,7 +78,7 @@ queue_set_size(size_t size) { if (size > QUEUE_MAX) #if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64) - fatal("Requested prefetch queue of %" PRIi64 " bytes is too big\n", size); + fatal("Requested prefetch queue of %zu bytes is too big\n", size); #else fatal("Requested prefetch queue of %i bytes is too big\n", size); #endif