feat(libc): implement fegetenv #5563
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5563"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-13T23:57:50Z.
What
Java 25 LAN / DNS (PPSA99869, #5501) imports
fegetenv(psx0YiAKm7k) fromlibSceLibcInternal.prx, and no AnyPS5 library exports it. With #5502 (sysctlnametomib, the current stop onmain) applied, the loader stops here:fegetenvfollows FreeBSD 11 amd64fenv.cand the 32-bytefenv_tofx86/fenv.h(unchanged onmain):fnstenvstores the 28-byte x87 environment,fldcwreloads the control word becausefnstenvmasks every x87 exception, MXCSR goes at 0x1c, and it returns 0. It is implemented in libc, since the loader also resolveslibSceLibcInternalimports againstlibc.prx, as foratanhf. A null pointer throws. The technical-debt entry records that the console'slibSceLibcInternalis 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
feddf7f4.fegetenvand its test sit next to_FltroundsandCheckNearbyint, out of the lines #5495 changes, andtools/pr_overlap.py --branchreports no overlap with open pull requests.guest_mathgainsCheckFegetenv. It sets the x87 control word to0x0f7e(IE unmasked, round toward zero) and MXCSR to0x7fa0, leaves a pending x87 divide-by-zero flag, then checks the control word, status word and MXCSR stored in the guestfenv_t, that the control word and MXCSR are unchanged afterwards, and that a null pointer throws. With thefldcwremoved the test fails (0xc0000409).PPSA99869-lan-dns-pass-01.000.000.zip, SHA-2563cfeed2f…11cc, as in #5501), run onmain30f96126before the rebase. I unwrappedeboot.binandsce_module/libc.prxfrom their fSELF containers and relinked with--windows --to-intel --trap-sdk-syscall-stubs --registry:main:FAIL: unresolved ELF import UkEV4hvMo1E from libkernel.prx(sysctlnametomib)main+ #5502:FAIL: unresolved ELF import psx0YiAKm7k from libSceLibcInternal.prx(fegetenv)main+ #5502 + this PR:FAIL: unresolved ELF import +hFjyohmOU0 from libkernel.prx(mincore, the next absent import #5501 lists)ctest(--parallel 4 --timeout 120) on the current head: 1108 of 1109 pass.windows_trace_importsfails locally only because Defender deletes its generatedoutput.exe(WinError 225); it fails the same way onmain.python tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-14T05:42:04Z.
Built and ran this on Windows: head
81104f731merged ontomainf5424b4db(no conflicts), Windows 11, WinLibs GCC 15.2.0, Ninja Release.guest_mathpasses. WithMath.cppput back tomainand the test kept, it doesn't link (undefined reference to fegetenv_nid_postfix).psx0YiAKm7k from libSceLibcInternal.prx; adding this PR it moves on to+hFjyohmOU0(mincore, #5643). So thelibc.prxexport does satisfy thelibSceLibcInternalimport on Windows.amd64/fenv.cL86-L97 and the amd64fenv_tinx86/fenv.hL81-L89: same steps (fnstenv, MXCSR at 0x1c,fldcwof the saved control word) and the same 32-byte layout. Doing thefldcwbefore reading MXCSR doesn't change anything. Nothing to add from my side.AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T12:00:06Z.
Progress report (
afc8541→ 81104f7)📈 System libraries: 88.19% (+0.01%, +1 implemented functions)
✅ 1 implemented
fegetenv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T12:05:48Z.
Checked
fegetenvagainst FreeBSD amd64fenv.cand the 32-bytefenv_t(fnstenv, control word reloaded, MXCSR at 0x1c).guest_mathpasses 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.