feat(libcinternal): implement float and double min/max vector helpers #15581

Merged
ashwin280802 merged 1 commit from upstream-pr/15581 into main 2026-11-10 06:32:09 +00:00
ashwin280802 commented 2026-11-03 20:09:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-03T20:09:47Z.


What

Implements the 12 float and double __std_min* / __std_max* / __std_minmax* vector helpers of libSceLibcInternal (value forms and element forms) and removes them from the recovered inventory. The integer variants are still throwing stubs and will follow in a separate PR.

Source: the scalar paths of Microsoft STL vector_algorithms.cpp at e1ed302683:

  • Value forms (L3330-L3341): strict <, the first equal element wins, for the minimum, the maximum and minmax alike.
  • Element forms (L3098-L3119): the same, except minmax_element returns the last largest (<=).
  • The three-argument element exports are ABI wrappers that forward to the two-argument forms and ignore the bool (L3666-L3674).

No console measurement and no Sony build was checked.

Deliberate divergences and unknowns, recorded in docs/dev/debt/libSceLibcInternal.md:

  • A range containing a NaN throws. The STL vector paths use _mm_min_ps / _mm_max_ps, so their result for a NaN depends on lane order, length and CPU, and the STL defines no NaN handling.
  • A range mixing +0.0 and -0.0 returns the scalar-path result; Sony's vector path may return the other zero or a different tie index.
  • The value forms throw for a null, empty, reversed or partial-element range. The element forms return first for an empty range, including two null pointers, and throw for the other invalid ranges.

Open-PR overlap: the comparison finds no other open PR that exports any of these 12 names. #15460, #15577 and #15657 edit the same inventory, header and debt entry for other exports, and #13782, #15822, #15931, #16005, #16343, #16356 and #16434 touch the same CMake list, so expect textual conflicts in the libSceLibcInternal CMakeLists.txt and debt file. The comparison could not be completed for #5021, #13778, #13881, #14212, #14834 and #16004 because they conflict with main; I have not compared them.

Tested

At 7eb3c06a2c (this patch before the last rebase onto main) on Windows 11 with MinGW GCC, ctest --test-dir build-full -R ^guest_libc_internal_vector_algorithms$ --output-on-failure:

1/1 Test #3201: guest_libc_internal_vector_algorithms ...   Passed    0.02 sec
100% tests passed out of 1

python3 tools/check_conventions.py --base origin/main: no violations.

I changed 20 conditions and statements in the new code one at a time and the test failed on all 20.

On Linux (Docker, lavapipe, at 7eb3c06a2c):

1/1 Test #3130: guest_libc_internal_vector_algorithms ...   Passed    0.00 sec

Other tests failed on this machine in code this change does not touch and are not investigated here. Windows: select_tests_MissingCommandTests, vulkan_validation_gate_commands and agc_driver_direct_write_completion. Linux: guest_mmap_executable aborts at GuestMemory.cpp:3576. I did not run these on main for this change.

Not verified: behaviour on a console; the tests named above on main.

Not covered by a test: none.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5143805278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15581). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-11-03T20:09:47Z. --- ### What Implements the 12 float and double `__std_min*` / `__std_max*` / `__std_minmax*` vector helpers of libSceLibcInternal (value forms and element forms) and removes them from the recovered inventory. The integer variants are still throwing stubs and will follow in a separate PR. Source: the scalar paths of Microsoft STL [`vector_algorithms.cpp`](https://github.com/microsoft/STL/blob/e1ed302683e5e822f663fbb0f44cee7e9ddc6af0/stl/src/vector_algorithms.cpp) at `e1ed302683`: - Value forms ([L3330-L3341](https://github.com/microsoft/STL/blob/e1ed302683e5e822f663fbb0f44cee7e9ddc6af0/stl/src/vector_algorithms.cpp#L3330-L3341)): strict `<`, the first equal element wins, for the minimum, the maximum and `minmax` alike. - Element forms ([L3098-L3119](https://github.com/microsoft/STL/blob/e1ed302683e5e822f663fbb0f44cee7e9ddc6af0/stl/src/vector_algorithms.cpp#L3098-L3119)): the same, except `minmax_element` returns the last largest (`<=`). - The three-argument element exports are ABI wrappers that forward to the two-argument forms and ignore the `bool` ([L3666-L3674](https://github.com/microsoft/STL/blob/e1ed302683e5e822f663fbb0f44cee7e9ddc6af0/stl/src/vector_algorithms.cpp#L3666-L3674)). No console measurement and no Sony build was checked. Deliberate divergences and unknowns, recorded in `docs/dev/debt/libSceLibcInternal.md`: - A range containing a NaN throws. The STL vector paths use `_mm_min_ps` / `_mm_max_ps`, so their result for a NaN depends on lane order, length and CPU, and the STL defines no NaN handling. - A range mixing `+0.0` and `-0.0` returns the scalar-path result; Sony's vector path may return the other zero or a different tie index. - The value forms throw for a null, empty, reversed or partial-element range. The element forms return `first` for an empty range, including two null pointers, and throw for the other invalid ranges. Open-PR overlap: the comparison finds no other open PR that exports any of these 12 names. #15460, #15577 and #15657 edit the same inventory, header and debt entry for other exports, and #13782, #15822, #15931, #16005, #16343, #16356 and #16434 touch the same CMake list, so expect textual conflicts in the libSceLibcInternal `CMakeLists.txt` and debt file. The comparison could not be completed for #5021, #13778, #13881, #14212, #14834 and #16004 because they conflict with `main`; I have not compared them. ### Tested At 7eb3c06a2c (this patch before the last rebase onto `main`) on Windows 11 with MinGW GCC, `ctest --test-dir build-full -R ^guest_libc_internal_vector_algorithms$ --output-on-failure`: ``` 1/1 Test #3201: guest_libc_internal_vector_algorithms ... Passed 0.02 sec 100% tests passed out of 1 ``` `python3 tools/check_conventions.py --base origin/main`: no violations. I changed 20 conditions and statements in the new code one at a time and the test failed on all 20. On Linux (Docker, lavapipe, at 7eb3c06a2c): ``` 1/1 Test #3130: guest_libc_internal_vector_algorithms ... Passed 0.00 sec ``` Other tests failed on this machine in code this change does not touch and are not investigated here. Windows: `select_tests_MissingCommandTests`, `vulkan_validation_gate_commands` and `agc_driver_direct_write_completion`. Linux: `guest_mmap_executable` aborts at `GuestMemory.cpp:3576`. I did not run these on `main` for this change. Not verified: behaviour on a console; the tests named above on `main`. Not covered by a test: none. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15581
No description provided.