feat(libc): implement log1p, log1pf and expm1 #3259
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3259"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T03:43:46Z.
Resubmission of #2173, which was closed because no title was shown stopping on these functions.
OpenRCT2 (PPSA99728) stops at
coshonmain961b25fe(implemented by #3190). With #3190 applied, it stops next atexpm1(gqKfOiJaCOo), per @babyhuey's run on #3190 (comment). So this becomes OpenRCT2's next stop as soon as #3190 lands, the same stacking as #2933 (llroundf) before #2932 (atol).log1p,log1pfandexpm1are still absent on currentmain, and no open PR implements them. There is no code dependency on #3190: the branch is rebased onto currentmainand merges cleanly with #3190. Windows 11 (WinLibs GCC 15.2.0), Release:guest_mathpasses 3/3, andcheck_conventions.pyandpr_overlap.py --branchpass.What
Exports
log1p,log1pfandexpm1. Each one forwards to the C++ standard library, likelogandexp. Only the variants that titles import are added.Titles: open-source homebrew from the #1578 catalog audit imports them from
libSceLibcInternal(resolved throughlibc.prx):log1p: PPSA68091 Ruffle, PPSA99169 RetroArchlog1pf: PPSA68091 Ruffleexpm1: PPSA99169 RetroArch, PPSA99764 PorpoiseI haven't run any of these titles.
Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:guest_math_tests, next tolog10f:log1p(-0)andexpm1(-0)are-0);log1p(-1) == -inf,log1p(inf) == inf,expm1(-inf) == expm1(-1000) == -1;log1p(-2),log1pf(-2);log1p(1e-300),log1pf(1e-30f)andexpm1(1e-300)return their argument, andlog1p(1e-10)/expm1(1e-10)are within 1e-25 of the exact values.log(1 + x)andexp(x) - 1give 0 or lose most digits there.log(1 + x)orexp(x) - 1makesguest_mathfail.cmake --build build --target libs: the patchedlibc.prxexports all 3 NIDs.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. This branch also merges cleanly with my #2158, #2166 and #2167.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:44:09Z.
Progress report (
961b25f→1f94d93)📈 System libraries: 86.02% (+0.02%, +3 implemented functions)
✅ 3 implemented
expm1_nid_postfixlog1p_nid_postfixlog1pf_nid_postfixImported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T04:10:22Z.
Full Linux and Windows builds and tests for this head (
1f94d93d), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(e28fbc27):ctest: 760/761 passedctest: 765/765 passedThe one Linux failure,
agc_unit_shadow, also fails onmainitself (push run 38098335801); this PR only touches libc math and its tests.Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38109323513
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T04:32:44Z.
Checked with #3190 under this head (
1f94d93d) onmain961b25fe, both merge cleanly. Linux (Ubuntu 24.04, GCC 13) and Windows 11 (WinLibs GCC 15.2), Release:guest_mathpasses 5/5 (--repeat until-fail:5) on both, with no warnings inMath.cpporGuestMath.cpp.OpenRCT2 (PPSA99728), Linux, catalog build with
sce_module/libc.prxunwrapped:app.elf: symbol lookup error: app.elf: undefined symbol: gqKfOiJaCOo(expm1)app.elf: symbol lookup error: app.elf: undefined symbol: 0hlfW1O4Aa4(localeconv, #545)On Windows the loader reports
FAIL: unresolved ELF import oxMp8uPqa+U (pthread_set_name_np) from libkernel.prx(#3031) first for OpenRCT2, with and without these PRs, so theexpm1step only shows on Linux.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:17:05Z.
Checked
log1p,log1pfandexpm1forward tostd::with the right float/double overloads, andguest_mathpasses on Linux. Without the change the new checks fail to link, so they exercise the new exports. OpenRCT2 stopping atexpm1after #3190 is confirmed in @babyhuey's run; merging.