feat(libc): implement __fpclassifyf #1987

Merged
babyhuey merged 1 commit from upstream-pr/1987 into main 2026-10-09 21:53:49 +00:00
babyhuey commented 2026-10-09 03:43:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T03:43:14Z.


What

Implements __fpclassifyf (z7aCCd9hMsI) in libc, as FreeBSD lib/libc/gen/fpclassify.c does: it classifies the IEEE single by its exponent and fraction bits and returns FreeBSD's <math.h> values, FP_INFINITE 0x01, FP_NAN 0x02, FP_NORMAL 0x04, FP_SUBNORMAL 0x08 and FP_ZERO 0x10, not the host's. Titles import it from libSceLibcInternal.

Why

It is a title's next stop on current main: PPSA99764 Porpoise stops on it on Linux and Windows.

Title main f1451396 with this branch
PPSA99764 Porpoise 2.5 (Linux) app.elf: symbol lookup error: app.elf: undefined symbol: z7aCCd9hMsI undefined symbol: 7p7kTAJcuGg (__inet_addr, #1972)
PPSA99764 Porpoise 2.5 (Windows) FAIL: unresolved ELF import z7aCCd9hMsI from libSceLibcInternal.prx not run

Tested

Linux (Ubuntu 24.04, GCC 13, Release): guest_math passes with --repeat until-fail:3. The existing _FDtest case table (both zeros, the smallest and largest subnormals, normals, both infinities, quiet and signalling NaNs) now also checks __fpclassifyf against the FreeBSD constants. The test fails when the zero and subnormal results are swapped. check_conventions.py passes. Windows: Math.cpp compiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only).

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:4795697097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T03:43:14Z. --- ### What Implements `__fpclassifyf` (`z7aCCd9hMsI`) in libc, as FreeBSD `lib/libc/gen/fpclassify.c` does: it classifies the IEEE single by its exponent and fraction bits and returns FreeBSD's `<math.h>` values, `FP_INFINITE` 0x01, `FP_NAN` 0x02, `FP_NORMAL` 0x04, `FP_SUBNORMAL` 0x08 and `FP_ZERO` 0x10, not the host's. Titles import it from `libSceLibcInternal`. ### Why It is a title's next stop on current `main`: PPSA99764 Porpoise stops on it on Linux and Windows. | Title | `main` f1451396 | with this branch | |---|---|---| | PPSA99764 Porpoise 2.5 (Linux) | `app.elf: symbol lookup error: app.elf: undefined symbol: z7aCCd9hMsI` | `undefined symbol: 7p7kTAJcuGg` (`__inet_addr`, #1972) | | PPSA99764 Porpoise 2.5 (Windows) | `FAIL: unresolved ELF import z7aCCd9hMsI from libSceLibcInternal.prx` | not run | ### Tested Linux (Ubuntu 24.04, GCC 13, Release): `guest_math` passes with `--repeat until-fail:3`. The existing `_FDtest` case table (both zeros, the smallest and largest subnormals, normals, both infinities, quiet and signalling NaNs) now also checks `__fpclassifyf` against the FreeBSD constants. The test fails when the zero and subnormal results are swapped. `check_conventions.py` passes. Windows: `Math.cpp` compiles with MinGW-w64 GCC 13 (`-Wall -Wextra -fsyntax-only`). ### 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
MarcZX10 commented 2026-10-09 04:05:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:05:49Z.

Review: COMMENTED


Reviewed the full diff: the bit masks correctly distinguish signed zero/subnormal/normal/infinity/NaN and return the FreeBSD constants rather than host FP_* values. The test reuses the existing IEEE boundary table, including both zero signs, subnormal endpoints, both infinities, and quiet/signalling NaNs. No code issue found. All three upstream workflows currently show action_required, so a maintainer must approve them before the checks can validate this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5465593186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987#pullrequestreview-5465593186). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T04:05:49Z. **Review:** COMMENTED --- Reviewed the full diff: the bit masks correctly distinguish signed zero/subnormal/normal/infinity/NaN and return the FreeBSD constants rather than host `FP_*` values. The test reuses the existing IEEE boundary table, including both zero signs, subnormal endpoints, both infinities, and quiet/signalling NaNs. No code issue found. All three upstream workflows currently show `action_required`, so a maintainer must approve them before the checks can validate this head.
babyhuey commented 2026-10-09 04:28:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T04:28:31Z.


Until the upstream workflows are approved: the same build.yml passes on my fork for this exact head (d5b231b): https://github.com/babyhuey/AnyPS5/actions/runs/37880560237

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074271074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987#issuecomment-6074271074). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T04:28:31Z. --- Until the upstream workflows are approved: the same build.yml passes on my fork for this exact head (d5b231b): https://github.com/babyhuey/AnyPS5/actions/runs/37880560237
MarcZX10 commented 2026-10-09 06:06:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:06:54Z.

Review: APPROVED


Reviewed the full diff and confirmed the classification masks return the FreeBSD values independently of the host FP_* constants. The test checks signed zeros, subnormal boundaries, normal values, infinities, and quiet/signaling NaNs. I built and ran the exact head on Linux with GCC 12: guest_math passed (1/1); conventions and diff checks pass. PR #1784 changes the double/long-double classifiers in the same files but adds different exports, so this is not duplicate work. Upstream checks have no results yet; the fork workflow evidence in the description is not an upstream check.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5466329483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987#pullrequestreview-5466329483). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T06:06:54Z. **Review:** APPROVED --- Reviewed the full diff and confirmed the classification masks return the FreeBSD values independently of the host FP_* constants. The test checks signed zeros, subnormal boundaries, normal values, infinities, and quiet/signaling NaNs. I built and ran the exact head on Linux with GCC 12: guest_math passed (1/1); conventions and diff checks pass. PR #1784 changes the double/long-double classifiers in the same files but adds different exports, so this is not duplicate work. Upstream checks have no results yet; the fork workflow evidence in the description is not an upstream check.
github-actions[bot] commented 2026-10-09 08:55:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T08:55:20Z.


Progress report (8b393b6 → eb20ba1)

📈 System libraries: 84.7% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc __fpclassifyf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077713812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987#issuecomment-6077713812). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T08:55:20Z. --- <!-- progress-report --> ### Progress report (8b393b6 → eb20ba1) 📈 **System libraries**: 84.7% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `__fpclassifyf_nid_postfix` | </details>
adriadam10 commented 2026-10-09 21:53:46 +00:00 (Migrated from github.com)

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


Checked on Linux: build and guest_math pass; without the change the test doesn't link. The masks and the returned constants (0x01 infinite, 0x02 NaN, 0x04 normal, 0x08 subnormal, 0x10 zero) match FreeBSD fpclassify.c, and the test reuses the existing _FDtest boundary table (both zeros, subnormal limits, infinities, quiet/signalling NaN). Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089888346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1987#issuecomment-6089888346). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:53:46Z. --- Checked on Linux: build and `guest_math` pass; without the change the test doesn't link. The masks and the returned constants (0x01 infinite, 0x02 NaN, 0x04 normal, 0x08 subnormal, 0x10 zero) match FreeBSD `fpclassify.c`, and the test reuses the existing `_FDtest` boundary table (both zeros, subnormal limits, infinities, quiet/signalling NaN). 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!1987
No description provided.