Skip to content

Commit 89e92fc

Browse files
author
Cycl0o0
committed
fix: isolate static host math symbols
1 parent 8a98fcd commit 89e92fc

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ patch release must remain ABI-compatible with its minor line.
3939
- The selected decompilation configuration and default 60 ms simulation step
4040
now match the exercised PAL 1.1 ROM.
4141
- Internal libultra compatibility functions now use liboot-prefixed symbols,
42-
preventing collisions when a static host supplies the same N64 functions.
42+
preventing collisions when a static host supplies the same N64 functions,
43+
including the incompatible `sins` and `coss` helpers used by SM64 ports.
4344
- Public documentation now describes liboot as a host-driven Link runtime and
4445
separates current capabilities from host responsibilities and limitations.
4546

‎CMakeLists.txt‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ target_compile_definitions(oot PRIVATE
9595
osSendMesg=liboot_internal_osSendMesg
9696
osRecvMesg=liboot_internal_osRecvMesg
9797
guPerspective=liboot_internal_guPerspective
98+
guMtxF2L=liboot_internal_guMtxF2L
99+
guMtxIdent=liboot_internal_guMtxIdent
100+
guMtxIdentF=liboot_internal_guMtxIdentF
101+
sins=liboot_internal_sins
102+
coss=liboot_internal_coss
98103
)
99104
if(BUILD_SHARED_LIBS)
100105
target_compile_definitions(oot PRIVATE LIBOOT_MULTI_INSTANCE=1)
@@ -214,8 +219,8 @@ if(BUILD_TESTING)
214219

215220
if(NOT BUILD_SHARED_LIBS)
216221
# Static game ports often carry their own libultra compatibility
217-
# layer. This executable deliberately owns the four names that have
218-
# collided in real hosts and must still link the complete engine.
222+
# layer. This executable deliberately owns names that have collided
223+
# in real hosts and must still link the complete engine.
219224
add_executable(liboot_static_namespace_test
220225
test/static_namespace_test.c
221226
)

‎Makefile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ OOT_DEFINES := -DLIBOOT_HOST_BUILD=1 -D_LANGUAGE_C -DNON_MATCHING -DAVOID_UB -DD
99
-DosCreateMesgQueue=liboot_internal_osCreateMesgQueue \
1010
-DosSendMesg=liboot_internal_osSendMesg \
1111
-DosRecvMesg=liboot_internal_osRecvMesg \
12-
-DguPerspective=liboot_internal_guPerspective
12+
-DguPerspective=liboot_internal_guPerspective \
13+
-DguMtxF2L=liboot_internal_guMtxF2L \
14+
-DguMtxIdent=liboot_internal_guMtxIdent \
15+
-DguMtxIdentF=liboot_internal_guMtxIdentF \
16+
-Dsins=liboot_internal_sins \
17+
-Dcoss=liboot_internal_coss
1318
CFLAGS := -g -Wall -Wno-unused-function -Wno-unused-variable \
1419
-fno-strict-aliasing -funsigned-char -fPIC -fvisibility=hidden \
1520
-DOOT_LIB_EXPORT -DLIBOOT_MULTI_INSTANCE=1 $(OOT_DEFINES) \

‎test/static_namespace_test.c‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,45 @@ void guPerspective(void)
2626
{
2727
}
2828

29+
void guMtxF2L(void)
30+
{
31+
}
32+
33+
void guMtxIdent(void)
34+
{
35+
}
36+
37+
void guMtxIdentF(void)
38+
{
39+
}
40+
41+
/* SM64 ports expose these names with floating-point return values. OoT's
42+
* libultra functions return signed fixed-point values, so accidentally
43+
* resolving either call to the host is an ABI mismatch, not just a duplicate
44+
* implementation. */
45+
float sins(int16_t angle)
46+
{
47+
(void)angle;
48+
return -0.25f;
49+
}
50+
51+
float coss(int16_t angle)
52+
{
53+
(void)angle;
54+
return -0.5f;
55+
}
56+
57+
int16_t liboot_internal_sins(uint16_t angle);
58+
int16_t liboot_internal_coss(uint16_t angle);
59+
2960
int main(void)
3061
{
31-
return oot_engine_api_version() == OOT_ENGINE_API_VERSION ? 0 : 1;
62+
if (oot_engine_api_version() != OOT_ENGINE_API_VERSION) {
63+
return 1;
64+
}
65+
if (liboot_internal_sins(0x4000u) < 32760 ||
66+
liboot_internal_coss(0u) < 32760) {
67+
return 2;
68+
}
69+
return 0;
3270
}

0 commit comments

Comments
 (0)