feat(libc): implement abs #1097

Closed
fardeen-hash wants to merge 1 commit from upstream-pr/1097 into main
fardeen-hash commented 2026-10-07 10:44:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fardeen-hash on 2026-10-07T10:44:32Z.


What

Implement standard ISO C / POSIX abs (NID Ye20uNnlglA), replacing the libcCyberUnknown02 stub in core/libs/prx/libc/Export.cpp which previously aborted on NotImplemented_nid_no_patch("Ye20uNnlglA").

  • Title that imports it: Cyberpunk 2077 (PPSA04029), already noted on main in core/libs/prx/libc/Export.cpp among the Cyberpunk 2077 imports.
  • Sources for signature and behavior:
    • ISO C (<stdlib.h>) & POSIX.1 (int abs(int)).
    • FreeBSD libc (/usr/include/stdlib.h), the upstream base for Sony's libc.prx.
    • Sony symbol database (aerolib.csv) and tools/nid_names.py, where compute_nid("abs") confirms NID Ye20uNnlglA.

Tested

Added unit test assertions in core/libs/tests/GuestMath.cpp covering zero, positive, negative, and INT_MAX cases.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4771479555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1097). Originally posted by [fardeen-hash](https://github.com/fardeen-hash) on 2026-10-07T10:44:32Z. --- ### What Implement standard ISO C / POSIX `abs` (NID `Ye20uNnlglA`), replacing the `libcCyberUnknown02` stub in `core/libs/prx/libc/Export.cpp` which previously aborted on `NotImplemented_nid_no_patch("Ye20uNnlglA")`. - **Title that imports it**: Cyberpunk 2077 (`PPSA04029`), already noted on `main` in `core/libs/prx/libc/Export.cpp` among the Cyberpunk 2077 imports. - **Sources for signature and behavior**: - ISO C (`<stdlib.h>`) & POSIX.1 (`int abs(int)`). - FreeBSD `libc` (`/usr/include/stdlib.h`), the upstream base for Sony's `libc.prx`. - Sony symbol database (`aerolib.csv`) and `tools/nid_names.py`, where `compute_nid("abs")` confirms NID `Ye20uNnlglA`. ### Tested Added unit test assertions in `core/libs/tests/GuestMath.cpp` covering zero, positive, negative, and `INT_MAX` cases. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
oneandonlydean commented 2026-10-08 03:25:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:25:42Z.


Does PPSA04029 call abs on main, or only import it? With the log line where it stops at Ye20uNnlglA this can go in; otherwise I'll close it until a title does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051538794 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1097#issuecomment-6051538794). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:25:42Z. --- Does PPSA04029 call `abs` on main, or only import it? With the log line where it stops at `Ye20uNnlglA` this can go in; otherwise I'll close it until a title does.
popcoder565 commented 2026-10-09 19:42:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:21Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head fca59673, merged onto main 8b393b6e in one build with 31 other PRs that had no Windows run.

  • This PR's tests pass: guest_math.
  • Full ctest in that build: 520 of 521. The one failure is guest_offline_imports, broken by #2359 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088017064 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1097#issuecomment-6088017064). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:42:21Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `fca59673`, merged onto `main` 8b393b6e in one build with 31 other PRs that had no Windows run. - This PR's tests pass: `guest_math`. - Full ctest in that build: 520 of 521. The one failure is `guest_offline_imports`, broken by #2359 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-09 21:21:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:21:32Z.

Review: CHANGES_REQUESTED


Thanks. Two things before this can land:

  • @oneandonlydean's question is still open: does PPSA04029 actually call abs, or only import it? Please post the log line where it stops at Ye20uNnlglA (or equivalent evidence from a run).
  • It now conflicts with main in core/libs/prx/libc/Export.cpp (the neighbouring stubs around libcCyberUnknown02 changed). Please rebase.

Optional: pin INT_MIN in the test (UB for std::abs; FreeBSD libc returns INT_MIN) or say in the description that it is not covered. The Windows run by @popcoder565 (guest_math passes) is noted.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5475467474 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1097#pullrequestreview-5475467474). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:21:32Z. **Review:** CHANGES_REQUESTED --- Thanks. Two things before this can land: - @oneandonlydean's question is still open: does PPSA04029 actually call `abs`, or only import it? Please post the log line where it stops at `Ye20uNnlglA` (or equivalent evidence from a run). - It now conflicts with `main` in `core/libs/prx/libc/Export.cpp` (the neighbouring stubs around `libcCyberUnknown02` changed). Please rebase. Optional: pin `INT_MIN` in the test (UB for `std::abs`; FreeBSD libc returns `INT_MIN`) or say in the description that it is not covered. The Windows run by @popcoder565 (`guest_math` passes) is noted.
github-actions[bot] commented 2026-10-09 21:36:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T21:36:11Z.


Progress report (0d3c1ee → fca5967)

📈 System libraries: 86.64% (+0.03%, +1 implemented, -1 removed functions)

✅ 1 implemented
Library Name
libc abs_nid_postfix
🗑️ 1 removed
Library Name
libc libcCyberUnknown02
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089657651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1097#issuecomment-6089657651). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T21:36:11Z. --- <!-- progress-report --> ### Progress report (0d3c1ee → fca5967) 📈 **System libraries**: 86.64% (+0.03%, +1 implemented, -1 removed functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `abs_nid_postfix` | </details> <details> <summary>🗑️ 1 removed</summary> | Library | Name | | - | - | | libc | `libcCyberUnknown02` | </details>

Pull request closed

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!1097
No description provided.