Fix undefined symbol error in libretro Nintendo 3DS build

This commit is contained in:
刘皓 2025-03-30 00:03:03 -04:00
parent afec0dc50d
commit 70c5b3dad4
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 35 additions and 1 deletions

View file

@ -305,6 +305,11 @@ if is_libretro
libretro_defines += '-DFLAC__INTEGER_ONLY_LIBRARY'
endif
if is_devkitarm
libretro_defines += '-D__DEVKITPRO__'
libretro_defines += '-D__DEVKITARM__'
endif
# Position-independent code is not supported on some platforms where we need to build a static library, e.g. https://github.com/vitasdk/vita-toolchain/issues/264
use_pic = not core_is_static

View file

@ -1,6 +1,35 @@
# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile OpenAL Soft.
# Fixes compilation errors when using the devkitARM toolchain toolchain to compile OpenAL Soft.
# For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM or Vita SDK even though they're the same size, so we have to do this whole song and dance to appease the compiler.
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -2114,7 +2114,7 @@ inline T SampleConv(float) noexcept;
template<> inline float SampleConv(float val) noexcept
{ return val; }
-template<> inline int32_t SampleConv(float val) noexcept
+template<> inline int SampleConv(float val) noexcept
{
/* Floats have a 23-bit mantissa, plus an implied 1 bit and a sign bit.
* This means a normalized float has at most 25 bits of signed precision.
@@ -2123,13 +2123,16 @@ template<> inline int32_t SampleConv(float val) noexcept
*/
return fastf2i(std::clamp(val*2147483648.0f, -2147483648.0f, 2147483520.0f));
}
+#ifdef __DEVKITARM__
+template<> inline long SampleConv(float val) noexcept { return (long)SampleConv<int>(val); }
+#endif
template<> inline int16_t SampleConv(float val) noexcept
{ return static_cast<int16_t>(fastf2i(std::clamp(val*32768.0f, -32768.0f, 32767.0f))); }
template<> inline int8_t SampleConv(float val) noexcept
{ return static_cast<int8_t>(fastf2i(std::clamp(val*128.0f, -128.0f, 127.0f))); }
/* Define unsigned output variations. */
-template<> inline uint32_t SampleConv(float val) noexcept
+template<> inline unsigned int SampleConv(float val) noexcept
{ return static_cast<uint32_t>(SampleConv<int32_t>(val)) + 2147483648u; }
template<> inline uint16_t SampleConv(float val) noexcept
{ return static_cast<uint16_t>(SampleConv<int16_t>(val) + 32768); }
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -83,16 +83,16 @@ inline DevFmtType_t<T> StoreSample(float) noexcept;