From 2b05477dd9cd99e7f9425f58cb544f454fc0d813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Pawe=C5=82=20Stefaniak?= <3462925+pstef@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:25:47 +0100 Subject: [PATCH 1/3] minizip: avoid trying to compile problematic code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trying to compile this libretro core on my Fedora aarch64 machine I was getting this error: mupen64plus-core/subprojects/minizip/zip.c:1249:28: error: assignment to ‘const long unsigned int *’ from incompatible pointer type ‘const uint32_t *’ {aka ‘const unsigned int *’} [-Wincompatible-pointer-types] 1249 | zi->ci.pcrc_32_tab = get_crc_table(); | ^ (redacted for clarity in this commit message) Curiously, mupen64plus-core having the same minizip code didn't suffer from this error. This is because there the problematic code has been disabled by using exclusion defines NOCRYPT and NOUNCRYPT. This commit tries to do the same for this repository. --- Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.common b/Makefile.common index b1425312..0ad9e907 100644 --- a/Makefile.common +++ b/Makefile.common @@ -158,6 +158,7 @@ ifeq ($(SYSTEM_MINIZIP), 1) CFLAGS += $(shell pkg-config --cflags minizip) LDFLAGS += $(shell pkg-config --libs minizip) else + PLATCFLAGS += -DNOCRYPT -DNOUNCRYPT INCFLAGS += $(MINIZIP_INCFLAGS) SOURCES_C += $(MINIZIP_SOURCES_C) endif From 26dfd670ffdd5ed6a03e6704dc73f82c13d81dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Pawe=C5=82=20Stefaniak?= <3462925+pstef@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:46:14 +0100 Subject: [PATCH 2/3] EmuThread: align with co_create() and pthread_create() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trying to compile this libretro core on my Fedora aarch64 machine I was getting: libretro/libretro.c:722:61: error: passing argument 2 of ‘co_create’ from incompatible pointer type [-Wincompatible-pointer-types] game_thread = co_create(65536 * sizeof(void*) * 16, EmuThreadFunction); (redacted for clarity in this commit message) The problem is that co_create() and pthread_create() are different APIs. While the former expects a void (*)(void), the latter expects a void * (*)(void *). This commit * redefines EmuThreadFunction so that it matches co_create() where it's used, and * creates a new wrapping function EmuThreadWrapper matching the function type expected by pthread_create(), where it's used. --- libretro/libretro.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 30990251..34dc1d5a 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -441,7 +441,7 @@ static void emu_step_initialize(void) plugin_connect_all(); } -static void* EmuThreadFunction(void* param) +static void EmuThreadFunction() { uint32_t netplay_port = 0; uint16_t netplay_player = 1; @@ -484,8 +484,13 @@ static void* EmuThreadFunction(void* param) // Unset emuThreadRunning = false; } +} - return NULL; +static void* EmuThreadWrapper(void* param) +{ + (void)param; + EmuThreadFunction(); + return NULL; } static void reinit_gfx_plugin(void) @@ -2014,7 +2019,7 @@ void retro_run (void) { if(!emuThreadRunning) { - pthread_create(&emuThread, NULL, &EmuThreadFunction, NULL); + pthread_create(&emuThread, NULL, &EmuThreadWrapper, NULL); emuThreadRunning = true; } } From 3c3e7fbc70b8f533c09c964cf468ba5e8d61351c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Pawe=C5=82=20Stefaniak?= <3462925+pstef@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:14:37 +0100 Subject: [PATCH 3/3] Fix compilation of bundled libzlib On my system it was missing the inclusion of unistd.h. Mimic what's been done for MacOSX and conditionally add -DHAVE_UNISTD_H for this library. --- Makefile.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.common b/Makefile.common index 0ad9e907..0b10785f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -176,6 +176,9 @@ ifeq ($(SYSTEM_ZLIB), 1) CFLAGS += $(shell pkg-config --cflags zlib) LDFLAGS += $(shell pkg-config --libs zlib) else +ifneq (,$(findstring unix,$(platform))) + PLATCFLAGS += -DHAVE_UNISTD_H +endif INCFLAGS += $(ZLIB_INCFLAGS) SOURCES_C += $(ZLIB_SOURCES_C) endif