feat(libc): implement nan and nanf #3315

Merged
pushkarreddyy merged 1 commit from upstream-pr/3315 into main 2026-10-11 08:49:06 +00:00
pushkarreddyy commented 2026-10-11 07:12:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T07:12:33Z.


What

Implement standard C99 quiet NaN generators nanf (DZU+K1wozGI) and nan (zck+6bVj5pA) in libc (core/libs/prx/libc/src/Math.cpp).

  • Returns standard IEEE-754 quiet NaN via std::nanf and std::nan.
  • Handles nullptr tag pointer safely by defaulting to empty string "".
  • Adds unit tests in core/libs/tests/GuestMath.cpp verifying quiet NaN generation, null/empty/custom tag strings, and sign bit correctness.
  • Documents technical debt in docs/dev/TechnicalDebt.md.

Resolves start-up failure in VLC for PS5 (PPSA85300, Issue #1578) on Linux, where execution stops at nanf after strsep (#3192).

Tested

  • Windows 11, unit tests in guest_math_tests exercising nanf_nid_postfix and nan_nid_postfix with null, empty, and tagged inputs.
  • python tools/check_conventions.py --base 1690db9a2 passes with zero findings.
  • git diff --check passes with zero whitespace issues.

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:4817311015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T07:12:33Z. --- ### What Implement standard C99 quiet NaN generators `nanf` (`DZU+K1wozGI`) and `nan` (`zck+6bVj5pA`) in `libc` (`core/libs/prx/libc/src/Math.cpp`). - Returns standard IEEE-754 quiet NaN via `std::nanf` and `std::nan`. - Handles `nullptr` tag pointer safely by defaulting to empty string `""`. - Adds unit tests in `core/libs/tests/GuestMath.cpp` verifying quiet NaN generation, null/empty/custom tag strings, and sign bit correctness. - Documents technical debt in `docs/dev/TechnicalDebt.md`. Resolves start-up failure in VLC for PS5 (`PPSA85300`, Issue #1578) on Linux, where execution stops at `nanf` after `strsep` (#3192). ### Tested - Windows 11, unit tests in `guest_math_tests` exercising `nanf_nid_postfix` and `nan_nid_postfix` with null, empty, and tagged inputs. - `python tools/check_conventions.py --base 1690db9a2` passes with zero findings. - `git diff --check` passes with zero whitespace issues. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
github-actions[bot] commented 2026-10-11 07:12:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T07:12:41Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106559953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315#issuecomment-6106559953). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T07:12:41Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
github-actions[bot] commented 2026-10-11 07:12:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T07:12:55Z.


Progress report (f8d8ae5 → 31906bf)

📈 System libraries: 85.55% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc nan_nid_postfix
libc nanf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106561600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315#issuecomment-6106561600). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T07:12:55Z. --- <!-- progress-report --> ### Progress report (f8d8ae5 → 31906bf) 📈 **System libraries**: 85.55% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `nan_nid_postfix` | | libc | `nanf_nid_postfix` | </details>
pushkarreddyy commented 2026-10-11 07:32:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T07:32:46Z.


The intake check closed this automatically. @adriadam10 @oneandonlydean @MarcZX100: Could one of you please reopen or carry this when convenient? It implements standard quiet NaN generators nanf (DZU+K1wozGI) and nan (zck+6bVj5pA) in libc, which is the immediate runtime stop for VLC for PS5 (PPSA85300, issue #1578) on Linux now that strsep (#3192) has landed. It is cleanly rebased and mergeable onto current main (bd0692590) with Mergeable: True, and passes all conventions and unit tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106711735 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315#issuecomment-6106711735). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T07:32:46Z. --- The intake check closed this automatically. @adriadam10 @oneandonlydean @MarcZX100: Could one of you please reopen or carry this when convenient? It implements standard quiet NaN generators `nanf` (`DZU+K1wozGI`) and `nan` (`zck+6bVj5pA`) in libc, which is the immediate runtime stop for *VLC for PS5* (PPSA85300, issue #1578) on Linux now that `strsep` (#3192) has landed. It is cleanly rebased and mergeable onto current `main` (`bd0692590`) with `Mergeable: True`, and passes all conventions and unit tests.
adriadam10 commented 2026-10-11 08:06:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:06:40Z.

Review: CHANGES_REQUESTED


Thanks for this. Two things to change:

  • core/libs/prx/libc/src/Math.cpp:128-129: the console's libc.prx ignores the tag. Both exports (zck+6bVj5pA, DZU+K1wozGI) just load a global constant and return it (mov rax,[rip+..]; vmovsd xmm0,[rax]; ret). std::nan(tag) instead puts a payload in the result on glibc ("123" → decimal 123), FreeBSD parses the tag as hex, and MinGW ignores it, so the result depends on the host. Return one fixed quiet NaN regardless of the tag (no std::nan) and say where its bits come from.
  • core/libs/tests/GuestMath.cpp:362-369: pin the exact bits (std::bit_cast) and use a tagged input that would change them on glibc ("123"), not just isnan.
  • docs/dev/TechnicalDebt.md:554: the line is the last one of the file, which conflicts as soon as anyone else appends. Move it a few lines up inside "Functional", and mention that the tag is ignored.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482490562 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315#pullrequestreview-5482490562). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:06:40Z. **Review:** CHANGES_REQUESTED --- Thanks for this. Two things to change: - `core/libs/prx/libc/src/Math.cpp:128-129`: the console's `libc.prx` ignores the tag. Both exports (`zck+6bVj5pA`, `DZU+K1wozGI`) just load a global constant and return it (`mov rax,[rip+..]; vmovsd xmm0,[rax]; ret`). `std::nan(tag)` instead puts a payload in the result on glibc (`"123"` → decimal 123), FreeBSD parses the tag as hex, and MinGW ignores it, so the result depends on the host. Return one fixed quiet NaN regardless of the tag (no `std::nan`) and say where its bits come from. - `core/libs/tests/GuestMath.cpp:362-369`: pin the exact bits (`std::bit_cast`) and use a tagged input that would change them on glibc (`"123"`), not just `isnan`. - `docs/dev/TechnicalDebt.md:554`: the line is the last one of the file, which conflicts as soon as anyone else appends. Move it a few lines up inside "Functional", and mention that the tag is ignored.
adriadam10 commented 2026-10-11 08:49:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:49:03Z.

Review: APPROVED


Checked against the console's libc.prx: nan (zck+6bVj5pA) and nanf (DZU+K1wozGI) load a global through a relocation whose targets hold 0x7ff8000000000000 and 0x7fc00000, which is what this returns regardless of the tag. guest_math passes and fails to link without the change; TechnicalDebt line is in place. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482626069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3315#pullrequestreview-5482626069). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:49:03Z. **Review:** APPROVED --- Checked against the console's `libc.prx`: `nan` (`zck+6bVj5pA`) and `nanf` (`DZU+K1wozGI`) load a global through a relocation whose targets hold `0x7ff8000000000000` and `0x7fc00000`, which is what this returns regardless of the tag. `guest_math` passes and fails to link without the change; TechnicalDebt line is in place. Merging.
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!3315
No description provided.