Improve determination of size of stbsp__uintptr in stb_sprintf

This commit is contained in:
刘皓 2025-07-31 21:36:25 -04:00
parent 917c3d735f
commit 9da4fc8540
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 15 additions and 12 deletions

View file

@ -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

View file

@ -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