feat(libc): implement unsigned 64-bit maximum #10460
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10460"
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-24T01:44:29Z.
What
Add
__std_max_8u(Lg0dYZuDrz4) to libc: it takes a nonempty range of unsigned 64-bit elements and returns the maximum value, rather than a pointer to that element. Read elements through the existingmemcpyhelper so unaligned ranges work, and leave the input untouched. Null, empty, reversed and partial-element ranges throw throughNotImplemented_nid_no_patch; their native failure behavior is not reproduced and is recorded in debt.This export is a real dependency of Marvel's Wolverine, PPSA03671 version 01.001.005 (bring-up discussion #5516). A fresh Windows conversion on original validation base
9232ee9c986e54c5c148ef36c729ea4c1c31408e, withunused-filter=2, retains its non-weaklibc.prximport and PLT stub at0x5f21f00. Direct calls at0x5ec9f89and0x5eca3a4were inspected; the first stores the returned 64-bit value. This is an import/dependency fix, not a claim that the title now boots or plays.Contract evidence:
libc.prxexports this NID at RVA0x63990, size0x2a4. Reading its implementation confirmsrdi/rsirange arguments, 8-byte elements, unsigned comparisons and a 64-bit result inrax. Its ELF SHA256 is483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6.Tested
Current-main synchronization (27 October 2026). Exact tested/published head:
7792cff8ef984f2f39d685dd1b1bc9e45a72c92a. Main base:cb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f.c862a8f34e900926260b7cbf3fcf1082be2e6ac3onto 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:
c862a8f34e900926260b7cbf3fcf1082be2e6ac3. Fetched main base:74acfad65b3f0fd4eab653f3a3989d298fba1157.62c85f44a6a50b0ffb6ae72e7d6405c5a8c7769f. The__std_max_8uproduction 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.38 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 c862a8f34e900926260b7cbf3fcf1082be2e6ac3 --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
Review follow-up (25 October 2026), published/tested head
62c85f44a6a50b0ffb6ae72e7d6405c5a8c7769f, base88f99678bff7345c2a7f83aefcf1b2a8a81c7498:__std_max_8uonce incore/libs/prx/libc/include/Api.hpp, next to the maximum-element declarations.libs,relinkerandguest_vector_algorithms_tests.ctest --test-dir build -R "^(guest_vector_algorithms|public_headers)$" -V --output-on-failure: 2/2 pass. An initial header audit while the full build was running exceeded its 30-second limit; the standalone audit passed, and the final CTest run after the build passed in 20.67 seconds without changing the timeout.BUILD_TESTING=ON: configured the full project from a temporary source copy taken from this head in Ubuntu's filesystem, built the production libc throughguest_vector_algorithms_tests, and ran the same CTest expression: 2/2 pass;public_headersfinished in 13.81 seconds. The runtime reported unavailable asynchronous userfaultfd write protection and used its existing memory-comparison fallback.Original 24 October validation:
Windows 11 build 26200, AMD Ryzen 7 3700X, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF,SDL_CCACHE=OFF.Original 24 October base:
9232ee9c986e54c5c148ef36c729ea4c1c31408e. Original published head:676c3ca4f971f1b02c26b979d13c3217b471a454. Code and tests were validated at39ff2ddc071afc7f57ee3e5be90b9b0c2653c236; the final amendment only moves the debt note beside the existing vector-algorithm entry. Both compiled source/test files were byte-identical to original head676c3ca4f971f1b02c26b979d13c3217b471a454.libs,relinkerandguest_vector_algorithms_testson main; the originalguest_vector_algorithmspasses.ctest --test-dir build -R "^guest_vector_algorithms$" --repeat until-fail:3 -V --timeout 25passes all three runs without skips.UINT64_MAX: 8,545 cases, zero mismatches between the original, the candidate reached through its patched NID, and an unsigned-maximum reference. The final restored production binary was compared again successfully. These are host executions of one original function, not console measurements.Lg0dYZuDrz4in built libc. Its conservative source classifier calls it a stub because unsupported-range guards still invokeNotImplemented; valid-range behavior was exercised through that exact NID. Other absent imports and throwing functions remain, so no title execution or unblock is claimed.Original 24 October overlap: the final required scan reports no confirmed overlap. The first scan found only three confirmed debt-note insertions (#8937, #10129, #10134); moving this note beside the vector entry separates them. The stale shared-file comparisons were inspected against each branch's merge base: all shared changes are in
docs/dev/debt/libc.md, with no changed vector-algorithm or__std_max_8uentry. The inspected PRs were #3965, #5021, #5303, #7081, #7544, #7648, #7715, #8150, #8306, #8417, #8863, #8965, #9133, #9232, #9408, #9447, #9526, #9527, #9552, #9669, #9833, #9844, #9873, #9929, #10002, #10003, #10007, #10113, #10226, #10229, #10234, #10245, #10247, #10253, #10265, #10274, #10283, #10306, #10314, #10315, #10316, #10317, #10321, #10325, #10328, #10346 and #10349. Their stale branches are not claimed merge-clean. No runtime dependency on those PRs is introduced.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-24T02:18:17Z.
Review: APPROVED
Reviewed head 676c3ca4f971f1b02c26b979d13c3217b471a454. The implementation matches the reported unsigned 64-bit value-returning ABI, handles unaligned reads via memcpy, and rejects malformed ranges before entering the scan loop. The regression cases cover unsigned/sign boundaries, varied lengths and alignments, input preservation, and invalid ranges; the PR also reports a differential run against the title-bundled export. All eligible hosted checks pass; Linux and Windows product jobs are skipped by workflow policy. I found no blocking issue in this scoped implementation.