feat(libc): implement guest-width first-set-bit exports #4129
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4129"
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 MiniRML on 2026-10-11T23:49:33Z.
What
Provide ffs/ffsl/ffsll with one-based bit positions and zero for zero input. ffsl uses the guest 64-bit long ABI on Windows. Tests cover every bit position, sign bits and inputs with multiple set bits.
These exports (ffs, ffsl, ffsll) are named in the pinned symbol database used by AnyPS5's
tools/nid_names.py. They are absent from the base implementation. The complete changed-file scan of 370 open PRs found no other added implementation of these exports. Related functions are kept together in one topic.Sources and compatibility
The guest ABI follows the existing libc implementation: 16-bit wide code units, 64-bit long/intmax types, and x87 extended precision in 16-byte storage where used. PS5 hardware validation was not performed. Math exports that delegate to host libm do not establish bit-for-bit agreement with the console's libm; their tested behavior and that limitation are stated here.
Tested
Windows 11, MinGW-w64 GCC 15.2.0, CMake 4.3.1, Ninja, Release,
BUILD_TESTING=ON. Tested commit5002c929405be13abfad1a05ac9e96056a9aef98, based on upstreambab7b3285221495463a4a2494dc410cf137b4a92.cmake --build build --target libc guest_libc_first_set_bit_tests -j 8passed.ctest --test-dir build -R '^guest_libc_first_set_bit$' --output-on-failure --no-tests=errorpassed (one behavioral regression test, multiple assertions).bab7b3285(HostPollundeclared). Upstream fixed it in merged #4021; the follow-up combined full build below passed.Checklist
Follow-up combined validation
Updated this branch to upstream
bca7a29d259299aaa8972c94d12694232bb3bb08without changing this topic's tested libc or regression source files. Current PR head:15951898c94b9445dc33ca95f91e404ba36cd4cb; independent tested head:5002c929405be13abfad1a05ac9e96056a9aef98.All 19 independent topics were then merged together on that upstream base in validation commit
f1721a1c6caebf3a95bdf312d06dbf2de7f938c0(saved in the fork undervalidation/libc-library-batch-2026-10-11):cmake --build build --target all libs -j 8passed on Windows 11.The earlier full-suite investigation remains paused. Linux runtime and PS5 hardware validation were not performed.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T23:53:06Z.
Progress report (
bca7a29→1595189)📈 System libraries: 86.49% (+0.02%, +3 implemented functions)
✅ 3 implemented
ffs_nid_postfixffsl_nid_postfixffsll_nid_postfixImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:26:48Z.
Same as #4122: no title is shown to reach this on main. Reopen with the title ID and the log line.
Pull request closed