feat(libSceLibcInternal): implement memrchr #1906
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1906"
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 Amirtheshwaran on 2026-10-08T23:14:52Z.
What
Adds the missing
memrchrexport tolibSceLibcInternal, implementing reverse byte search. Homebrew title ProsperoRadio (PPSA99001) imports it fromlibSceLibcInternal.prx(#1578).The backwards loop is implemented directly rather than calling a host runtime function because
memrchris a GNU extension absent from Windows runtimes. Searches match the last occurrence ofc(converted tounsigned char) within the firstnbytes, returningnullptrifn == 0or no match is found.Note: Touches the same
extern "C"block inlibSceLibcInternal/Export.cppas #1852 (atoll) and #1869 (getprogname), andGuestThreadAtexit.cppas #1869.Tested
libSceLibcInternal.prxexportsmemrchr_nid_postfix(renamed to5G2ONUzRgjY).ctest -R guest_thread_atexitpasses with the newmemrchrassertions.python tools/check_conventions.py --base origin/mainpasses with zero errors.git diff --checkpasses.GuestThreadAtexit.cppcovering:n == 0returnsnullptrwithout readings(including whens == nullptr)unsigned charrange (truncated before comparison)nullptrChecklist
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T23:15:17Z.
Progress report (
f145139→109aef1)➖ System libraries: 84.76% (+0.0%, +1 implemented functions)
✅ 1 implemented
memrchr_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T23:28:05Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceLibcInternal/Export.cppL106core/libs/prx/libSceLibcInternal/Export.cppL106core/libs/tests/GuestThreadAtexit.cppL12, L58Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:42:52Z.
Review: APPROVED
Correct, clean
memrchr(backwardsmemchr). Handles then == 0edge case, castsint ctounsigned char(so values like 0x142/0x200 correctly compare their low byte), and returns the last match or nullptr. The test covers the happy path, not-found, binary data with embedded NULs, and the int→byte truncation — good coverage for a one-line function.Minor: the test lives in
GuestThreadAtexit.cpp, which is otherwise about thread atexit destructors. Amemrchrtest doesn't belong there — consider moving it to a string/mem test file (or a new one) so the suite stays organized.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:31Z.
Closing: ProsperoRadio (PPSA99001) stops on the missing
libSceOpusDec.prxon main, and PICO-8 reachesmemrchronly after five other missing imports (#1578). Reopen when it's a title's next stop on main, with the log line.Pull request closed