Skip to content

feat(libc): implement __fpclassifyf - #1987

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libc-fpclassifyf
Oct 9, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libc-fpclassifyf

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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 f145139 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

@github-actions github-actions Bot added the libc label Oct 9, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Progress report (8b393b6 → eb20ba1)

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

✅ 1 implemented
Library Name
libc __fpclassifyf_nid_postfix

@babyhuey
babyhuey force-pushed the feat/libc-fpclassifyf branch from e53d4d9 to eb20ba1 Compare October 9, 2026 19:30
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 merged commit e2713aa into boykopovar:main Oct 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants