Skip to content

feat(libc): implement abs - #1097

Closed
fardeen-hash wants to merge 1 commit into
boykopovar:mainfrom
fardeen-hash:feat/libc-abs
Closed

fardeen-hash wants to merge 1 commit into
boykopovar:mainfrom
fardeen-hash:feat/libc-abs

Conversation

@fardeen-hash

Copy link
Copy Markdown

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

Implement standard ISO C/POSIX abs (Ye20uNnlglA), replacing the libcCyberUnknown02 stub imported by Cyberpunk 2077 (PPSA04029) that previously aborted on NotImplemented. Add unit tests in GuestMath.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

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 8b393b6 in one build with 31 other PRs that had no Windows run.

No title was run.

🤖 Addressed by Claude Code

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 9, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants