feat(libSceLibcInternal): implement unsigned byte extrema #15460
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15460"
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 mkrieger95 on 2026-11-03T12:21:22Z.
What
Implement
__std_min_1u(JkTHJqCAwss) and__std_max_1u(EY5VhjRs2Ns) inlibSceLibcInternal, replacing two throwing inventory declarations. They return the smallest or largest unsigned byte in a nonempty half-open range and leave the input unchanged.The signatures and valid-range behavior follow Microsoft's public STL
vector_algorithms.cpp: twoconst void*endpoints and auint8_tresult. Its scalar reduction reads an initial element, so a valid range is nonempty. This implementation throwsstd::invalid_argumentfor null, empty or reversed ranges instead of invoking the source algorithm with invalid input.The physical-module map contains both NIDs in
libSceLibcInternal. The exact Sony implementation, PS5 ABI and invalid-input behavior remain unmeasured and are recorded indocs/dev/debt/libSceLibcInternal.md. The remaining placeholder count is reduced from 40 to 38.The reductions are written against that public contract; no third-party source or dependency is added. No SIMD-equivalence, speed or title-unblock claim is made.
Tested
Linux x86-64, GCC 14.2, Release,
BUILD_TESTING=ON; based on upstream4f41f4c375f5abb487dbd184fbc150f31994d762. Tested head:446b5d63fd6f1927018055b4af55a3ca58ebfb40on 2026-11-03 UTC.libSceLibcInternal,guest_libc_internal_byte_extrema_testsandguest_vector_algorithms_tests.guest_libc_internal_min_byte,guest_libc_internal_max_byte,guest_vector_algorithms.not implementederrors. Replacing unsigned comparisons with signed-byte comparisons makes both fail their unsigned-ordering assertion. The committed implementation was then restored byte-for-byte, rebuilt and both tests passed again.python3 core/libs/tests/test_public_headers.py --audit-only: 406 libraries, 28,302 exports pass.python3 tools/check_conventions.py --base origin/mainandgit diff --check: pass.tools/nid_names.py --name __std_min_1u --name __std_max_1u --whereconfirms both NIDs. A patched copy of the production library exports each NID exactly once.Not tested: Windows, macOS, a title or a PS5. No console-parity or whole-project-build claim.
Overlap:
python3 tools/pr_overlap.py --branch feat/libc-internal-byte-extrema --repo boykopovar/AnyPS5checked 1,675 open upstream PRs against4f41f4c375f5abb487dbd184fbc150f31994d762. Completed comparisons report no conflicting lines, same exports or same new files. It exits 2 because existing base conflicts prevent full comparisons with #5021, #13486, #13778, #13782, #14158, #14212, #14401, #14837 and #14936. Every reported shared CMake/debt file was compared manually using its common ancestor: merging this head produces exactly the same conflict hunks as merging unmodified main. None of those patches changes either helper or adds this test. The change adds no overlap requiring a landing-order dependency or author coordination.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-11-03T12:55:59Z.
Review: APPROVED
Reviewed — looks good
I found no blocking issue at this head, and all applicable hosted checks have completed successfully.
What I ran
Reviewed all five changed files at head
446b5d63fd6f1927018055b4af55a3ca58ebfb40against base4f41f4c375f5abb487dbd184fbc150f31994d762. The exact head previews cleanly against currentmain. Environment: Debian 12 x86_64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. I did not build or run CTest; test results below are author-reported.Results
Precheck table and check output
The NID lookup returned
__std_min_1u→JkTHJqCAwssand__std_max_1u→EY5VhjRs2Ns. The test-quality helper warned that it could not find a literal test source path in CMake; inspection confirms the source is passed through${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalByteExtrema.cppand both CTest entries are present.Exact
gh pr checksoutput at final refresh:Relevant Windows job log lines:
Negative control
Findings
Blocking
None found in the reviewed source.
Non-blocking
The PR reports focused tests and negative controls on Linux, but I did not reproduce them locally. Console ABI and invalid-range behavior remain unmeasured, as the PR records. Linux and specialized hosted jobs were skipped.
Sources
Not verified
I did not run a local build, CTest, either reported negative control, Windows/macOS/Linux runtime tests, or console behavior. The hosted Windows job is pending; Linux and specialized hosted jobs were skipped.
To get this to a good state
No code change is requested for this head. If the head changes, I will review the new diff and rerun applicable checks.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T13:06:59Z.
Review: APPROVED
Reviewed — approved
__std_min_1uand__std_max_1uwork correctly on valid ranges, the focused tests pass on the merged tree, and the new tests fail under both negative controls I ran myself.What I ran
Head
446b5d63fd6f1927018055b4af55a3ca58ebfb40merged with--no-ffintomain4f41f4c375f5abb487dbd184fbc150f31994d762(merged tree5594b63da4e643d1c308860bc1eb829f4d73acf7). Machine: Debian 13 VM, 2× Xeon Gold 6136 (32 vCPU), GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pyguest_libc_internal_min_byte,guest_libc_internal_max_byteguest_vector_algorithmspublic_headersmaingit status --porcelainempty)Negative control output
Negative control
The PR has no new production file, and restoring
RecoveredInventory.cppfrommainwhile keeping the new header would not compile. So I applied two mutations to the merged file instead:NotImplemented_nid_no_patch(__func__): both new tests fail ("not implemented").std::int8_t): both tests fail the unsigned-ordering assertion.After each mutation I restored the merged file, rebuilt, and both tests passed again. The author's description reports the same two controls, and the earlier review by MarcZX10 marked them as not reproduced. They are now reproduced.
Findings
Blocking
None.
Non-blocking
Invalid ranges are handled differently from the sibling exports in libc. At
core/libs/prx/libSceLibcInternal/RecoveredInventory.cpp:7, null, empty or reversed ranges throwstd::invalid_argumentthroughAPS5_INVALID_ARG_EX. The existing__std_min_8uand__std_max_8iincore/libs/prx/libc/src/VectorAlgorithms.cpp:142and:161treat the same inputs as unimplemented and callNotImplemented_nid_no_patch(__func__). Both follow the rule that every function either works or throws, and the PR records this behaviour in the debt entry. However:__func__here expands toByteExtremum, so the error does not name the guest export.Suggestion: either pass the export name into the helper, or follow the
VectorAlgorithms.cpppattern. Optionally, put the byte variants next to the other__std_min_*/__std_max_*helpers later.A tiny point: the header uses
std::uint8_tthroughSceTypes.hppwithout including<cstdint>itself.public_headerscompiles fine, so this works today.Not verified