Skip to content

feat(libc): implement fegetenv - #5563

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
karimibrahim07:feat/libc-fegetenv
Oct 14, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
karimibrahim07:feat/libc-fegetenv

Conversation

@karimibrahim07

@karimibrahim07 karimibrahim07 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Java 25 LAN / DNS (PPSA99869, #5501) imports fegetenv (psx0YiAKm7k) from libSceLibcInternal.prx, and no AnyPS5 library exports it. With #5502 (sysctlnametomib, the current stop on main) applied, the loader stops here:

FAIL: unresolved ELF import psx0YiAKm7k from libSceLibcInternal.prx

fegetenv follows FreeBSD 11 amd64 fenv.c and the 32-byte fenv_t of x86/fenv.h (unchanged on main): fnstenv stores the 28-byte x87 environment, fldcw reloads the control word because fnstenv masks every x87 exception, MXCSR goes at 0x1c, and it returns 0. It is implemented in libc, since the loader also resolves libSceLibcInternal imports against libc.prx, as for atanhf. A null pointer throws. The technical-debt entry records that the console's libSceLibcInternal is assumed to have the same code and layout.

Tested

Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Release. The branch is rebased onto feddf7f. fegetenv and its test sit next to _Fltrounds and CheckNearbyint, out of the lines #5495 changes, and tools/pr_overlap.py --branch reports no overlap with open pull requests.

  • guest_math gains CheckFegetenv. It sets the x87 control word to 0x0f7e (IE unmasked, round toward zero) and MXCSR to 0x7fa0, leaves a pending x87 divide-by-zero flag, then checks the control word, status word and MXCSR stored in the guest fenv_t, that the control word and MXCSR are unchanged afterwards, and that a null pointer throws. With the fldcw removed the test fails (0xc0000409).
  • Java 25 LAN / DNS PPSA99869 01.000.000 (PPSA99869-lan-dns-pass-01.000.000.zip, SHA-256 3cfeed2f…11cc, as in Java 25 LAN / DNS (PPSA99869) #5501), run on main 30f9612 before the rebase. I unwrapped eboot.bin and sce_module/libc.prx from their fSELF containers and relinked with --windows --to-intel --trap-sdk-syscall-stubs --registry:
  • Full ctest (--parallel 4 --timeout 120) on the current head: 1108 of 1109 pass. windows_trace_imports fails locally only because Defender deletes its generated output.exe (WinError 225); it fails the same way on main.
  • python tools/check_conventions.py --base origin/main passes.

Checklist

🤖 Generated with Claude Code

@pipe1os

pipe1os commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Built and ran this on Windows: head 81104f731 merged onto main f5424b4db (no conflicts), Windows 11, WinLibs GCC 15.2.0, Ninja Release.

AI-assisted.

@github-actions

Copy link
Copy Markdown

Progress report (afc8541 → 81104f7)

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

✅ 1 implemented
Library Name
libc fegetenv_nid_postfix

karimibrahim07 and others added 4 commits October 14, 2026 14:02
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked fegetenv against FreeBSD amd64 fenv.c and the 32-byte fenv_t (fnstenv, control word reloaded, MXCSR at 0x1c). guest_math passes with the change and fails to link without it. Null pointer throws, TechnicalDebt entry records the assumption about the console's library.

Added one commit: moved the TechnicalDebt line out of the end of its section to avoid adjacency conflicts. Rebased onto current main; merging once CI is green.

@adriadam10
adriadam10 merged commit 45d99da into boykopovar:main Oct 14, 2026
12 checks passed
@karimibrahim07
karimibrahim07 deleted the feat/libc-fegetenv branch October 14, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants