Repository navigation
feat(libc): implement __umodti3 - #4462
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
Kart PS5 (PPSA99611, Phi1ow/mkwii-ps5 v1.0.0-rc1) stops on it right after __divti3. The related open PR boykopovar#4037 reports: "with this change it passes `__divti3` and stops at `ELSr5qm4K1M` (`__umodti3`)". PS5CEMU-HAR (PPSA99360) imports it too: tools/import_audit.py lists ELSr5qm4K1M __umodti3 as absent from libSceLibcInternal.prx (registry index 359), so the predicted stop is "FAIL: unresolved ELF import ELSr5qm4K1M from libSceLibcInternal.prx". libSceLibcInternal imports fall back to libc.prx, so the export lives in libc beside __udivti3. compute_nid and aerolib (zecoxao/sce_symbols 2883963a) both give ELSr5qm4K1M = __umodti3. __umodti3 is compiler-rt's lib/builtins/umodti3.c (llvm-project 0ee439b705e82a4fe20e266bc8fea96d0e60e1ec): the remainder that __udivmodti4 leaves. The restoring division of SonyUdivti3 already computes it, so the loop moves to SonyUdivmod128 and both helpers use it. A zero divisor reaches a 64-bit divide in __udivmodti4 and traps on x86-64; this throws instead, as __udivti3 does, and names the dividend. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
9 tasks done
10 tasks done
This was referenced Oct 12, 2026
10 tasks done
10 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #4460. Carries @screamm's fix branch from that issue (
screamm:feat/libc-umodti3,2d3ac3d5), keeping the commit and its authorship, as the issue invites.libc lacks
__umodti3(NIDELSr5qm4K1M). Kart PS5 (PPSA99611) stops on it right after__divti3(#4037 reports the stop), and PS5CEMU-HAR (PPSA99360) imports it too. The division loop ofSonyUdivti3moves into a sharedSonyUdivmod128helper that returns the quotient and the remainder;SonyUdivti3behaves as before andSonyUmodti3returns the remainder, as compiler-rt'sumodti3.cdoes. A zero divisor throws and names the dividend, as__udivti3throws. The export sits in libc beside__udivti3, sincelibSceLibcInternalimports fall back tolibc.prx. A TechnicalDebt entry sits beside the__udivti3one.Since the branch was cut, #4037 (
__divti3) merged and touched the same two spots, as the issue expected. I resolved the conflict when cherry-picking:SonyCrt.hppkeepsSonyDivti3after the new helpers (it callsSonyUdivti3), and inGuestCrt.cppthe new cases follow the__divti3ones, with theirmaximumrenamed tounsignedMaximumbecause__divti3's tests already declare amaximumin the same scope. Nothing else changed.Tested
guest_crt3/3 and 606/606 ofctest -E "^agc_driver_|^video_out_flip".mainfb23e85.guest_crtpasses, and withmain'sSonyCrt.hppandRuntimeSupport.cppit does not build (the export does not exist there). All 304guest_*tests pass.FAIL: unresolved ELF import ELSr5qm4K1M from libc.prxonmain, gets past it and stops atgacfOmO8hNs(ceil).tools/check_conventions.py --base upstream/mainpasses.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)__divti3, verified by the title run above; I found no Game bring-up discussion for it🤖 Generated with Claude Code