From 1e052e5dc0ca0d521def9260e94262686ddea6b3 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 20 Nov 2024 11:23:24 -0300 Subject: [PATCH 1/2] Use plat_mmap on the dynarecs as well --- src/codegen/codegen_x86-64.c | 19 ++----------------- src/codegen/codegen_x86.c | 19 ++----------------- src/codegen_new/codegen_allocator.c | 13 ++----------- 3 files changed, 6 insertions(+), 45 deletions(-) diff --git a/src/codegen/codegen_x86-64.c b/src/codegen/codegen_x86-64.c index 16d8a16f6..59f411612 100644 --- a/src/codegen/codegen_x86-64.c +++ b/src/codegen/codegen_x86-64.c @@ -7,6 +7,7 @@ # include # define HAVE_STDARG_H # include <86box/86box.h> +# include <86box/plat.h> # include "cpu.h" # include "x86.h" # include "x86_flags.h" @@ -25,14 +26,6 @@ # include "codegen_ops.h" # include "codegen_ops_x86-64.h" -# if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) -# include -# include -# endif -# if _WIN64 -# include -# endif - int codegen_flat_ds; int codegen_flat_ss; int codegen_flags_changed = 0; @@ -68,15 +61,7 @@ static int last_ssegs; void codegen_init(void) { -# if _WIN64 - codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); -# elif defined(PROT_MPROTECT) - codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_ANON | MAP_PRIVATE, -1, 0); -# elif defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) - codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); -# else - codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t)); -# endif + codeblock = plat_mmap(BLOCK_SIZE * sizeof(codeblock_t), 1); codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *)); memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index 09ae8697c..df0ed3bfd 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -44,6 +44,7 @@ # include # include # include <86box/86box.h> +# include <86box/plat.h> # include "cpu.h" # include <86box/mem.h> # include "x86.h" @@ -64,14 +65,6 @@ # include "codegen_ops.h" # include "codegen_ops_x86.h" -# ifdef __unix__ -# include -# include -# endif -# if defined _WIN32 -# include -# endif - int codegen_flat_ds; int codegen_flat_ss; int mmx_ebx_ecx_loaded; @@ -1194,15 +1187,7 @@ gen_MEM_CHECK_WRITE_L(void) void codegen_init(void) { -# ifdef _WIN32 - codeblock = VirtualAlloc(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); -# elif defined(PROT_MPROTECT) - codeblock = mmap(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_ANON | MAP_PRIVATE, 0, 0); -# elif defined __unix__ - codeblock = mmap(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0); -# else - codeblock = malloc((BLOCK_SIZE + 1) * sizeof(codeblock_t)); -# endif + codeblock = plat_mmap((BLOCK_SIZE + 1) * sizeof(codeblock_t), 1); codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *)); memset(codeblock, 0, (BLOCK_SIZE + 1) * sizeof(codeblock_t)); diff --git a/src/codegen_new/codegen_allocator.c b/src/codegen_new/codegen_allocator.c index 3aba72f59..3cdb731b9 100644 --- a/src/codegen_new/codegen_allocator.c +++ b/src/codegen_new/codegen_allocator.c @@ -13,6 +13,7 @@ #include <86box/86box.h> #include "cpu.h" #include <86box/mem.h> +#include <86box/plat.h> #include <86box/plat_unused.h> #include "codegen.h" @@ -33,17 +34,7 @@ int codegen_allocator_usage = 0; void codegen_allocator_init(void) { -#if defined WIN32 || defined _WIN32 || defined _WIN32 - mem_block_alloc = VirtualAlloc(NULL, MEM_BLOCK_NR * MEM_BLOCK_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - /* TODO: check deployment target: older Intel-based versions of macOS don't play - nice with MAP_JIT. */ -#elif defined(PROT_MPROTECT) - mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0); -#elif defined(__APPLE__) && defined(MAP_JIT) - mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0); -#else - mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); -#endif + mem_block_alloc = plat_mmap(MEM_BLOCK_NR * MEM_BLOCK_SIZE, 1); for (uint32_t c = 0; c < MEM_BLOCK_NR; c++) { mem_blocks[c].offset = c * MEM_BLOCK_SIZE; From 393b1ba04a404de1b7b7a179eb4a2d2b92ff6db5 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 20 Nov 2024 16:15:39 -0300 Subject: [PATCH 2/2] Jenkins: Lock MacPorts to an older openal-soft while 10.x support is uncertain, fixes #4980 --- .ci/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.ci/build.sh b/.ci/build.sh index 2a48d564b..bf23f5d38 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -539,6 +539,12 @@ then sudo sed -i -e 's/configure.env-append MAKE=/configure.env-append VULKAN_SDK=${prefix} MAKE=/g' "$qt5_portfile" fi + # Patch openal-soft to use 1.23.1 on all targets instead of 1.24.0 on >=11.0 only, + # to prevent a symlink mismatch from having different versions on x86_64 and arm64. + # See: https://github.com/macports/macports-ports/commit/9b4903fc9c76769d476079e404c9a3b8a225f8aa + openal_portfile="$macports/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/audio/openal-soft/Portfile" + sudo sed -i -e 's/if {${os.platform} ne "darwin" || ${os.major} >= 21}/if {0}/g' "$openal_portfile" + # Patch wget to remove libproxy support, as it depends on shared-mime-info which # fails to build for a 10.13 target, which we have to do despite wget only being # a host dependency. MacPorts issue 69406 strongly implies this will not be fixed.