feat(libc): implement ffs, ffsl, ffsll, labs and imaxabs #1977
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1977"
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 Pedroj-64 on 2026-10-09T03:37:31Z.
What
ffs,ffsl,ffsll,labsandimaxabswere not exported.ffs*return the 1-based index of the least significant set bit, 0 for 0.labsandimaxabsnegate in unsigned arithmetic, so the minimum value maps to itself instead of overflowing.core/libs/prx/libc/src/Math.cpp: the five functions.guest_mathtest: zero, negative values, bits above 32 and the minimum values.Tested
Linux (CachyOS), GCC 16.2.1, Release.
tools/check_conventions.py --base upstream/mainpasses.Not tested on Windows or macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:41:16Z.
Review: COMMENTED
The PR currently contains two commits:
feat(libc): implement strsep and memccpy(the exact head commit of open PR #1976) plus the ffs/labs commit. Since this PR targetsmain, its diff duplicates #1976, while the checklist saysDepends on: none. Could you either rebase this branch ontomainwith only the ffs/labs commit, or make the dependency/stack explicit and update the base/description to match the project workflow? This will keep the contribution one-topic and avoid overlapping changes being merged twice.Imported from boykopovar/AnyPS5. Originally posted by Pedroj-64 on 2026-10-09T03:45:11Z.
Thanks for catching that. I rebased the branch onto current
mainand it now contains only the ffs/ffsl/ffsll/labs/imaxabs commit, so the diff no longer overlaps with #1976 and "Depends on: none" is accurate.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:46:39Z.
Review: COMMENTED
One cross-platform ABI issue remains: this project targets an LP64 guest, but native
longis 32 bits on Windows.Math.cppalready documents this for guestlroundand usesstd::int64_t; these newlabs/ffslsignatures andunsigned longarithmetic instead use the host width. On Windows,ffslcannot see bits 32–63,labshas the wrong return width, and0x100000000Lin the test is not a 64-bit value. Please use the project’s 64-bit guest-long type (std::int64_t, withstd::uint64_tfor bit operations) forlabs/ffsland make those test values explicitly 64-bit. This needs a Windows build/test before the PR is ready.Imported from boykopovar/AnyPS5. Originally posted by Pedroj-64 on 2026-10-09T04:00:20Z.
Good catch, thanks.
labsandffslnow usestd::int64_t(andstd::uint64_tfor the negation andcountr_zero), aslrounddoes, so they are 64-bit on Windows too. The test declarations use the same types and theffslvalue isINT64_C(0x100000000).Linux: the full suite (494 tests) passes and
tools/check_conventions.py --base upstream/mainpasses. I could not run Windows locally, so I am relying on the Windows CI job for it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:02:45Z.
Review: COMMENTED
I verified commit
44f2875: the duplicate #1976 commit is gone, andlabs/ffslplus their tests now use 64-bit guest-long types. That resolves both review points. GitHub currently reports no checks for this head, though the description says Windows CI will validate the ABI fix. Please request/trigger the checks; I can finish the review once they report on this exact head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:05:10Z.
Review: COMMENTED
The new head’s runs are now visible as
action_requiredfor Build, Conventions, and Progress report (all on44f2875). That is the repository’s workflow-approval gate, not a source failure. A maintainer must approve the runs; once they complete, I can verify Windows CI and finalize the review.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:57:08Z.
Same as #1976: please reopen with the title and the log line if one reaches these on main.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:03:56Z.
First Windows run, since the description says it wasn't tested on Windows.
Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto
mainb7218b3ctogether with nine other small libc/libkernel PRs: #1975, #1976, #1859, #1685, #1676, #1675, #1641, #1656, #1807.guest_mathpasses.🤖 Addressed by Claude Code
Pull request closed