From 9da4fc85406ecea345ebef61609583fb25656ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Thu, 31 Jul 2025 21:36:25 -0400 Subject: [PATCH] Improve determination of size of `stbsp__uintptr` in stb_sprintf --- meson.build | 10 ++++++++++ subprojects/packagefiles/stb-uintptr.patch | 17 +++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 3b182618..755ec7ce 100644 --- a/meson.build +++ b/meson.build @@ -45,6 +45,12 @@ endif sizeof = {'void*': compilers['cpp'].sizeof('void*'), 'long': compilers['cpp'].sizeof('long') } +if sizeof['void*'] <= 0 + error('Failed to detect size of void*') +endif +if sizeof['long'] <= 0 + error('Failed to detect size of long') +endif win64 = (sizeof['void*'] != sizeof['long']) android_api_level = host_system == 'android' ? compilers['c'].get_define('__ANDROID_API__').to_int() : 0 @@ -71,6 +77,10 @@ else global_args += '-DHAVE_NANOSLEEP' endif +if sizeof['void*'] <= 4 + global_args += '-DMKXPZ_32_BIT_POINTER' +endif + if (get_option('libretro_force_fat_lto') or (core_is_static and not is_emscripten)) and get_option('b_lto') global_args += '-ffat-lto-objects' endif diff --git a/subprojects/packagefiles/stb-uintptr.patch b/subprojects/packagefiles/stb-uintptr.patch index 6a2b7a16..0c483b44 100644 --- a/subprojects/packagefiles/stb-uintptr.patch +++ b/subprojects/packagefiles/stb-uintptr.patch @@ -1,20 +1,13 @@ -# Forces `stbsp__uintptr` to be a 64-bit unsigned integer on every platform. +# Changes the type of `stbsp__uintptr` to use Meson's detection of 32-bit platforms instead of hardcoding based on preprocessor defines. --- a/stb_sprintf.h +++ b/stb_sprintf.h -@@ -230,11 +230,11 @@ STBSP__PUBLICDEC void STB_SPRINTF_DECORATE(set_separators)(char comma, char peri +@@ -230,7 +230,7 @@ STBSP__PUBLICDEC void STB_SPRINTF_DECORATE(set_separators)(char comma, char peri #define stbsp__uint16 unsigned short #ifndef stbsp__uintptr -#if defined(__ppc64__) || defined(__powerpc64__) || defined(__aarch64__) || defined(_M_X64) || defined(__x86_64__) || defined(__x86_64) || defined(__s390x__) -+ ++#ifndef MKXPZ_32_BIT_POINTER #define stbsp__uintptr stbsp__uint64 --#else --#define stbsp__uintptr stbsp__uint32 --#endif -+ -+ -+ - #endif - - #ifndef STB_SPRINTF_MSVC_MODE // used for MSVC2013 and earlier (MSVC2015 matches GCC) + #else + #define stbsp__uintptr stbsp__uint32