Skip to content

Commit 70c5b3d

Browse files
committed
Fix undefined symbol error in libretro Nintendo 3DS build
1 parent afec0dc commit 70c5b3d

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ if is_libretro
305305
libretro_defines += '-DFLAC__INTEGER_ONLY_LIBRARY'
306306
endif
307307

308+
if is_devkitarm
309+
libretro_defines += '-D__DEVKITPRO__'
310+
libretro_defines += '-D__DEVKITARM__'
311+
endif
312+
308313
# 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
309314
use_pic = not core_is_static
310315

subprojects/packagefiles/openal-soft-int32.patch

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile OpenAL Soft.
1+
# Fixes compilation errors when using the devkitARM toolchain toolchain to compile OpenAL Soft.
22
# 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.
33

4+
--- a/alc/alu.cpp
5+
+++ b/alc/alu.cpp
6+
@@ -2114,7 +2114,7 @@ inline T SampleConv(float) noexcept;
7+
8+
template<> inline float SampleConv(float val) noexcept
9+
{ return val; }
10+
-template<> inline int32_t SampleConv(float val) noexcept
11+
+template<> inline int SampleConv(float val) noexcept
12+
{
13+
/* Floats have a 23-bit mantissa, plus an implied 1 bit and a sign bit.
14+
* This means a normalized float has at most 25 bits of signed precision.
15+
@@ -2123,13 +2123,16 @@ template<> inline int32_t SampleConv(float val) noexcept
16+
*/
17+
return fastf2i(std::clamp(val*2147483648.0f, -2147483648.0f, 2147483520.0f));
18+
}
19+
+#ifdef __DEVKITARM__
20+
+template<> inline long SampleConv(float val) noexcept { return (long)SampleConv<int>(val); }
21+
+#endif
22+
template<> inline int16_t SampleConv(float val) noexcept
23+
{ return static_cast<int16_t>(fastf2i(std::clamp(val*32768.0f, -32768.0f, 32767.0f))); }
24+
template<> inline int8_t SampleConv(float val) noexcept
25+
{ return static_cast<int8_t>(fastf2i(std::clamp(val*128.0f, -128.0f, 127.0f))); }
26+
27+
/* Define unsigned output variations. */
28+
-template<> inline uint32_t SampleConv(float val) noexcept
29+
+template<> inline unsigned int SampleConv(float val) noexcept
30+
{ return static_cast<uint32_t>(SampleConv<int32_t>(val)) + 2147483648u; }
31+
template<> inline uint16_t SampleConv(float val) noexcept
32+
{ return static_cast<uint16_t>(SampleConv<int16_t>(val) + 32768); }
433
--- a/core/converter.cpp
534
+++ b/core/converter.cpp
635
@@ -83,16 +83,16 @@ inline DevFmtType_t<T> StoreSample(float) noexcept;

0 commit comments

Comments
 (0)