Skip to content

feat(libc): implement unsigned 64-bit minimum - #11289

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Danigamer05:feat/libc-unsigned-min64
Oct 26, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Danigamer05:feat/libc-unsigned-min64

Conversation

@Danigamer05

Copy link
Copy Markdown
Contributor

What

Add the missing libc export __std_min_8u (i8DeU1sI6I4). It reads a nonempty range of unsigned 64-bit elements and returns the minimum value, rather than a pointer. Reads use the existing memcpy helper, so the range need not be aligned; the input is left untouched. Null, empty, reversed or partial-element ranges call NotImplemented_nid_no_patch; their native failure behavior is not reproduced and remains in debt. The test does not assert those unsupported paths.

The contract comes from the libc.prx bundled with PPSA03671 v01.001.005: export RVA 0x62a30, size 0x2a4, ELF SHA256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6. Its implementation takes rdi/rsi range pointers, reads 8-byte elements, selects the unsigned smaller value (cmovb at 0x62cc6 in the scalar tail), and returns the value in rax. The isolated original function was also executed on this Windows host from its mapped load segments, using its image-relative constants without relocations, module initialization or other module exports. This is a host differential, not a console measurement. Microsoft STL's public implementation corroborates the unsigned value-returning signature.

Declare the export once in libc's public Api.hpp; tests use that header. No third-party code, module bytes or title files are added. No current title dependency or title unblock is claimed.

Tested

Base: acb900c194325b9ee8c23c10768a9a491454f0b2. Published/tested head: 94e88881d482031d47178adcbe87a58212d3a304.

  • Windows 11 build 26200, AMD Ryzen 7 3700X, WinLibs MinGW-w64 GCC 15.2.0 r7, CMake 4.3.1, Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_RELINKER_ONLY=OFF, SDL_CCACHE=OFF. Built production libs, relinker and guest_vector_algorithms_tests.
  • The original guest_vector_algorithms passes on the unmodified base. Added cases cover unsigned/sign and 32/64-bit boundaries, a single value, repeated minima, lengths around vector/tail boundaries, offsets 0–31, input/canary preservation, all-maximum ranges and a unique minimum at every position. All existing cases remain.
  • Three independently rebuilt negative controls fail as expected: signed comparison, truncating later elements to 32 bits, and skipping the last element. Restored exact sources and binaries afterward.
  • ctest --test-dir build -R "^(guest_vector_algorithms|public_headers)$" -V --output-on-failure: both pass on Windows. The public-header audit verifies unique declarations and umbrella coverage; this is not a claim that all standalone-header compilation batches or the full CTest suite ran.
  • Isolated original / NID-patched production candidate / unsigned-minimum reference: 8,609 cases, zero mismatches. This includes lengths 1–257 at offsets 0–31, 256 cases against inaccessible guard pages, every single-bit boundary, zero/UINT64_MAX, and all 64 pairs of eight unsigned edge values. Inputs remain unchanged. Repeated against the final production binary after restoration.
  • Ubuntu 24.04 under WSL2 (kernel 6.6.114.1), GCC 13.3.0, CMake 3.28.3, Release, bundled dependencies: full-project configuration, production libc and guest_vector_algorithms_tests build; the same CTest expression passes both tests. A separate Git checkout fixed to the published commit is clean for the tested sources before and after the run. The existing runtime reported unavailable asynchronous userfaultfd write protection and used its memory-comparison fallback.
  • Conventions and PR-diff whitespace checks pass. No console, title run, macOS, full CTest suite, GPU execution or performance claim.

Overlap: the required scan against acb900c194325b9ee8c23c10768a9a491454f0b2 reports no confirmed overlap. Manually inspected all 29 stale shared-file comparisons against their merge bases: #5021, #5303, #6713, #7081, #7386, #7447, #7544, #7648, #7715, #8150, #8417, #9269, #9371, #9447, #9526, #9669, #9771, #9863, #9873, #9929, #10007, #10113, #10226, #10405, #10467, #10610, #10742, #10788, #10898. Their changes touch other debt entries; #10742 adds _LCosh/_LSinh declarations and #10788 adds _Thrd_lt, away from this declaration. None changes this export or the adjacent vector-algorithm entry. Those stale branches are not claimed merge-clean. A trial merge-tree with #10460 (62c85f44a6a50b0ffb6ae72e7d6405c5a8c7769f, unsigned maximum) succeeds without content conflicts; the two exports are independent.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

Copy link
Copy Markdown

Progress report (898a7fe → 94e8888)

📉 System libraries: 50.22% (-0.01%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libc __std_min_8u_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1357/1367 (99.27%) 1357/1368 (99.20%) -0.07 pp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head 94e88881d482031d47178adcbe87a58212d3a304. The unsigned 64-bit minimum implementation handles the nonempty range through the existing Read helper, including unaligned inputs; the added tests cover boundaries, random vectors, offsets, and guard/canary behavior. I found no concrete correctness issue in the diff.

The author reports Windows and WSL builds/differential tests (8,609 cases). Hosted conventions, eligibility, intake, labels, Ubuntu/macOS/Windows relinker, ASan, register-context, and write-watch checks pass. Full Linux and Windows product builds were path-skipped. I did not independently rerun the author’s local differential tests.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6713 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 7851 core/libs/prx/libc/include/Api.hpp
PR 8150 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9648 docs/dev/debt/libc.md
PR 9677 docs/dev/debt/libc.md
PR 9772 core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 9863 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 9953 docs/dev/debt/libc.md
PR 9964 docs/dev/debt/libc.md
PR 10002 docs/dev/debt/libc.md
PR 10007 docs/dev/debt/libc.md
PR 10234 docs/dev/debt/libc.md
PR 10315 docs/dev/debt/libc.md
PR 10317 docs/dev/debt/libc.md
PR 10321 docs/dev/debt/libc.md
PR 10324 core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 10325 docs/dev/debt/libc.md
PR 10328 docs/dev/debt/libc.md
PR 10345 docs/dev/debt/libc.md
PR 10349 docs/dev/debt/libc.md
PR 10405 docs/dev/debt/libc.md
PR 10467 docs/dev/debt/libc.md
PR 10506 docs/dev/debt/libc.md
PR 10510 docs/dev/debt/libc.md
PR 10512 docs/dev/debt/libc.md
PR 10529 docs/dev/debt/libc.md
PR 10565 docs/dev/debt/libc.md
PR 10749 core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 10895 docs/dev/debt/libc.md
PR 10903 docs/dev/debt/libc.md
PR 11121 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11341 docs/dev/debt/libc.md

@wachi35676

Copy link
Copy Markdown
Contributor

Windows run of head 94e88881d482 merged onto main 0f34ebb85, WinLibs GCC 15.2.0, Release. guest_vector_algorithms passes 2/2 with no warnings. I also merged this together with #11295 and #11300 onto main. All three merge cleanly in any order, including docs/dev/debt/libc.md, and the combined guest_vector_algorithms passes 3/3. So the three can land in any order.

AI-assisted: yes (Claude Code); results above were run on this machine.

@oneandonlydean oneandonlydean self-assigned this Oct 26, 2026
@oneandonlydean
oneandonlydean merged commit c739a47 into boykopovar:main Oct 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants