From 8e224f98516144722076e79b372c67ba7ded7577 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Sat, 11 Feb 2023 14:47:30 +0000 Subject: [PATCH] Support compiling without posix_memalign() function Add NO_POSIX_MEMALIGN option in Makefile.libretro to support platform that don't provide the posix_memalign() function. Signed-off-by: Paul Cercueil --- Makefile | 3 ++- Makefile.libretro | 3 +++ frontend/libretro.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cf2ea886..c95f4223 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ CFLAGS += -O2 -DNDEBUG endif endif CFLAGS += -DHAVE_MMAP=$(if $(NO_MMAP),0,1) \ - -DHAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) + -DHAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \ + -DHAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) CXXFLAGS += $(CFLAGS) #DRC_DBG = 1 #PCNT = 1 diff --git a/Makefile.libretro b/Makefile.libretro index 9f196387..42843bc6 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -210,6 +210,7 @@ else ifeq ($(platform), libnx) CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -DHAVE_INTTYPES -DLSB_FIRST -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections CFLAGS += -ftree-vectorize CFLAGS += -Ifrontend/switch -ftree-vectorize + NO_POSIX_MEMALIGN := 1 NO_PTHREAD=1 LIBPTHREAD := STATIC_LINKING=1 @@ -265,6 +266,7 @@ else ifeq ($(platform), vita) ARCH = arm STATIC_LINKING = 1 NO_PTHREAD=1 + NO_POSIX_MEMALIGN := 1 # CTR(3DS) else ifeq ($(platform), ctr) @@ -289,6 +291,7 @@ else ifeq ($(platform), ctr) ARCH = arm HAVE_NEON = 0 STATIC_LINKING = 1 + NO_POSIX_MEMALIGN := 1 # Xbox 360 else ifeq ($(platform), xenon) diff --git a/frontend/libretro.c b/frontend/libretro.c index 177b1500..329c5bcc 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -3039,7 +3039,7 @@ void retro_init(void) #ifdef _3DS vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80); -#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA) && !defined(__SWITCH__) +#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && HAVE_POSIX_MEMALIGN if (posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2) != 0) vout_buf = (void *) 0; #else -- 2.39.2