feat(libc): implement signed 32-bit maximum value helper #11333
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11333"
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 Danigamer05 on 2026-10-26T03:59:27Z.
What
Implement libc's
__std_max_4i(GE0yqFd83PA) for nonempty ranges of signed 32-bit integers. Return the maximum value, allow unaligned input, and leave the range unchanged. Null, empty, reversed and partial-element ranges callNotImplemented_nid_no_patch; the remaining native failure behavior is recorded in libc's debt file. The implementation is a generic scalar reduction using the existing unaligned read helper.Contract evidence: the user's own PPSA03671 v01.001.005 bundled
libc.prx, ELF SHA256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6, dynamic exportGE0yqFd83PA, RVA0x63430, size0x1a2. The entry usesrdi/rsias the range bounds;0x63453reads one 32-bit value,0x63470usesvpmaxsd, and the scalar tail at0x635c3/0x635c5selects with signedcmovle. The result reachesretat0x635d1ineax. Complete 16-byte blocks are bounded by the rounded-down byte length, and the remaining reads advance by four to the exclusive end. The function has no stores or calls. Empty input has no separate result path and enters a read. This is disassembly and direct execution on a host, not a console measurement; no original initializer or other original export was executed.The two-pointer signature and
int32_tresult are also corroborated by Microsoft STL at b6f01e438b68ee497f9c08313e49d12bb2f0d8e0. The implementation was written from the module's contract, without copying its SIMD structure. No game files, binary bytes, dumps or keys are included.Tested
Documentation-overlap follow-up (27 October 2026). Exact tested/published head:
f139bcf1fc29cca5d3e26c90e7704f9fa04f5298. Main base:f2f759ae31f2e51f767b8eb83c6c7e7132cab6d8.__std_max_4idebt entry beside the existing vector-helper entries, away frommalloc_stats_fast. Every preexisting byte of main's debt file is preserved; the contribution adds only this one entry there. This removes the documentation collision with #11870 without adding a dependency on it.e94b418a71cd4bdcd0c2e547c8d379c15bff2d21(main basecb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f) onto the main base above.VectorAlgorithms.cppandGuestVectorAlgorithms.cppare byte-identical to that previous published head. Main's new API declarations are retained, with the existing unique__std_max_4ideclaration preserved. The contribution still changes only its original four files.guest_vector_algorithms_testson this exact head.ctest --test-dir build -R "^(guest_vector_algorithms|public_headers)$" -V --output-on-failurepasses 2/2 on Windows (21.40 s) and 2/2 on Ubuntu (15.15 s). Bundled dependencies use this main base's pinned revisions, including its updated Vorbis pin.f2f759ae31f2e51f767b8eb83c6c7e7132cab6d8and found no confirmed line, export or new-file overlap. Its comparison with the previous remote revision of #11333 itself was excluded by PR identity; every other PR and its dependency relations were retained. In addition, normalized #11333 and #11870 merge without conflicts in both orders, producing the same tree and retaining both debt entries. This is a content-merge check; #11870 was not part of the runtime test.__std_max_4ior NIDGE0yqFd83PA. These stale branches are not claimed merge-clean or runtime-tested together.The full CTest suite, console, title and GPU execution were not run for this follow-up. The earlier native differential, negative controls and combined-helper evidence below retain their stated historical revisions; they were not rerun for this documentation relocation and rebase. No performance or title-unblock claim.
Earlier validation on historical revisions
Current-main synchronization (27 October 2026). Exact tested/published head:
e94b418a71cd4bdcd0c2e547c8d379c15bff2d21. Main base:cb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f.1c8e0b3895ac358e13072881359e012195210c79onto the two newer main commits. Main changed only thewindows_crash_stack_wordstest regex incore/libs/prx/libc/CMakeLists.txt(#11633). The entire four-file contribution patch is byte-identical before and after the rebase; no implementation or regression assertion changed.guest_vector_algorithms_testsin the existing full-project Release configurations.guest_vector_algorithmsandpublic_headerspass 2/2 on Windows 11 / WinLibs GCC 15.2.0 and 2/2 on Ubuntu 24.04 WSL / GCC 13.3.0.7da0577e45f238c6bfa01a818bd7e27f727ebeffalso builds and passes both focused tests on Windows and Ubuntu. This synchronization ran 32 focused checks in total across the seven individual heads and the combined head.a27d73c1f43135378c54ed6477af71273135ec42; only the unrelated upstream CMake regex differs. The previous original-module differential, standalone-header and AddressSanitizer evidence below retains its stated revisions and was not rerun for this synchronization.Earlier implementation validation and provenance
Current-main refresh (27 October 2026). Exact tested/published head:
1c8e0b3895ac358e13072881359e012195210c79. Fetched main base:74acfad65b3f0fd4eab653f3a3989d298fba1157.fdf8c3f156ab43443871fec3e66548d9a4d6c824. The__std_max_4iproduction body is byte-identical to that head. Every existing main declaration and debt entry is preserved; the patch still changes only the implementation, public declaration, regression cases and debt entry.guest_vector_algorithms_tests;ctest --test-dir build -R "^(guest_vector_algorithms|public_headers)$" -V --output-on-failurepassed 2/2 on this exact head (19.34 s).a27d73c1f43135378c54ed6477af71273135ec42also builds and passes both focused checks on Windows and Ubuntu.92db947130efc9e7e12c492683329f2ebc3e1996merges cleanly with the main base, each individual helper and the seven-helper composition. This is a content-merge check for #10788; its implementation was not part of the combined runtime run.tools/check_main_sync.py --base origin/main --head 1c8e0b3895ac358e13072881359e012195210c79 --strictpass. The sync check is one ahead and zero behind the fetched main base above. Bundled dependencies use that base's pinned revisions; no contribution dependency was introduced.public_headersaudits unique declarations and umbrella coverage. Its current upstream 90-second timeout is unchanged. The full set of 64 standalone-header batches and the full CTest suite were not run; the targeted header checks below were added afterward.Additional validation on 27 October 2026, combined revision
a27d73c1f43135378c54ed6477af71273135ec42(the same seven-helper composition described above):include/Api.hpp,include/exceptions/Runtime.hpp,include/exceptions/Unwind.hpp,include/SonyCrt.hpp, andlibc.hpp), plus a compilation unit including all 368 library umbrellas together, pass with C++20 and-Werroron Windows/WinLibs GCC 15.2.0 and Ubuntu/GCC 13.3.0. Every header is included twice, and the existing checker also rejects third-party header dependencies: 6 compilation units per platform, all pass. This is targeted coverage, not the full 64-batch matrix.ANYPS5_ENABLE_ASAN=ON, RelWithDebInfo, rebuilt libc andguest_vector_algorithms_tests.ASAN_OPTIONS=halt_on_error=1:detect_leaks=1 ctest --test-dir build-asan-libc-followup-20261027-a -R '^guest_vector_algorithms$' -V --output-on-failurepassed 1/1, with no AddressSanitizer or LeakSanitizer finding.The earlier differential and negative-control results below belong to their stated heads. The original-module differential was not rerun for this refresh. No console, title or GPU execution and no performance claim.
Earlier implementation validation and provenance
Current-main refresh (26 October 2026), exact published/tested head
fdf8c3f156ab43443871fec3e66548d9a4d6c824, main basebf77a9e9cba4b02c358779b35295176dd9cae164:ba233b8bd27773084ebb9130775eee7d1e8b094conto the main base above. All existing main declarations and debt entries are retained. The__std_max_4iproduction function body is byte-identical to the previously reviewed head; the patch still changes only its implementation, public declaration, regression cases and debt entry.guest_vector_algorithms_tests;ctest --test-dir build -R "^(guest_vector_algorithms|public_headers)$" -V --output-on-failurepassed 2/2 on this exact head (19.07 s).public_headersis the unique-declaration and umbrella-coverage audit; standalone-header compilation batches and the full CTest suite were not run in this refresh.tools/check_conventions.py --base origin/main, PR-diff whitespace checks andtools/check_main_sync.py --base origin/main --head fdf8c3f156ab43443871fec3e66548d9a4d6c824 --strictpass. The sync check reports one commit ahead and zero behind the fetched main base above.The previous baseline, differential and negative-control evidence below belongs to the earlier heads stated there. The original-module comparison was not rerun for this rebase-only refresh, and no console measurement was made.
Earlier implementation validation and provenance
Base:
943ea8acb23f0a1b2af35d85393fe6fd5afb7743. Tested/published head:ba233b8bd27773084ebb9130775eee7d1e8b094c.libs,relinkerandguest_vector_algorithms_testson baseline33ae5a31469994957f006ccb68dd0c3b9081e42eand initial candidated368be3e90948cd3537d9b2351fdc04562d5fda3. Both focused tests passed. After rebasing onto current main, rebuilt libc and the focused executable, reran both tests and the original/candidate differential: pass. The rebase only adds upstream shader changes; the libc and vector-test sources are byte-identical to the initial candidate.guest_vector_algorithms_tests, and passed the same two tests on the baseline and the final change. WSL reports the existing asynchronoususerfaultfdwrite-watch fallback to memory comparison; this is a host test, not a console measurement.INT32_MIN/INT32_MAX, deterministic random data, 20 lengths from 1 through 257, all 32 byte offsets, repeated values, the maximum at every position, and unchanged inputs and canaries. Unsupported-input throws are not pinned by tests.guest_vector_algorithmsandpublic_headerstogether on Ubuntu. They remain independent contributions.tools/check_conventions.py --base origin/mainpassed.tools/pr_overlap.py --branch feat/libc-signed-max32found no confirmed line, export or new-file overlap. Shared-file patches from 22 PRs already conflicting withmainwere checked separately: all 24 per-file merges retain exactly the same preexisting conflict blocks with this patch.public_headersis the unique-declaration and umbrella-coverage audit; standalone-header compilation batches and the full CTest suite were not run.Investigation scripts, evidence and logs remain outside the repository. No title bring-up or performance improvement is claimed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T04:13:19Z.
Review: APPROVED
Reviewed the complete diff at
ba233b8bd27773084ebb9130775eee7d1e8b094c. The implementation uses signedint32_tcomparisons, reads potentially unaligned elements through the existingRead<T>helper, validates the byte range before walking it, and does not modify the input. The regression additions cover signed boundaries, randomized ranges, lengths and offsets, repeated values, max positions, and immutability. I also checked the reported export disassembly and focused Windows/WSL differential evidence in the PR description. Current hosted relinker, ASan, register-context, write-watch, eligibility, intake, conventions, labels and report checks pass; product builds are skipped by path policy. No blocking issue found.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T06:01:36Z.
Review: DISMISSED
The implementation and evidence are otherwise strong: signed comparisons and unaligned reads match the stated range contract; the tests cover boundaries, offsets, lengths, unchanged input and negative controls; hosted checks pass, while full product builds are accurately reported as skipped.
This branch is 1 ahead and 55 behind current
main(14c99b52ac), with a clean merge preview. The only changed path also touched on currentmainisdocs/dev/debt/libc.md(from #9269); the implementation, declaration and test files have no intervening changes. Please rebase to resolve that debt-file overlap and rerunguest_vector_algorithmspluspublic_headerson the refreshed head before merge, as required by the repository's current-main sync rule.