feat(libc): implement feupdateenv #9232
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9232"
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 UnhealthyKraken on 2026-10-21T15:54:36Z.
What
libSceLibcInternalimports offeupdateenv(YXQ4gXamCrY) have no implementation in the shared libc provider. Restore the supplied 32-byte x87/MXCSR environment, then raise the union of the previously pending flags in both units and executefwait, following FreeBSD 11.4 amd64 fenv.c. This preserves the saved rounding, precision, masks, tags and instruction state while delivering enabled x87 exceptions during the call.The name/NID is corroborated by the public 3.20 inventory and symbol database; the signature and layout follow the public SDK fenv.h. Console behavior and module/library versions remain unmeasured and are recorded in debt. Null inputs and host-unsupported MXCSR bits throw before changing state. No host default-environment sentinel is substituted for the still-missing
__fe_dfl_envobject.This implementation builds independently of the other open fenv contributions.
Tested
Windows x86-64, GCC 15.2 Release. No games or GPU workloads were run.
fegetenvround trips and two concurrent host threads.libsbuild and final CTest selection: 22/22 pass, including 360 patched libraries loaded, 0 failed. A separate single-libc host fixture also passes the main test and all 18 traps through canonical NIDs. Its first attempt mixed patched/unpatched libc instances and terminated on the null-input exception; correcting the fixture's imports to use the patched personality and canonical dependency exports resolves that harness failure without a library change.Linux/macOS and console execution are unavailable here. The POSIX trap source checks
SIGFPEwithout inspecting the specific signal-context flag; it was not run here. Compilation and export presence are not claimed as console behavior proof.Current-main review follow-up
Merged main
d6e7ab42dfe191818721c6c5ad9aee4070b434aawithout rewriting published history; head5dfd50502a067ef8b4c141bb030fc78a35803789. Resolved only the adjacent libc debt conflict with merged #9296, preserving its snprintf/vsnprintf entry and this PR's feupdateenv note. Moved the latter next to the existing fegetenv entries as suggested in review. The original feupdateenv runtime/test implementation is retained.Rebuilt affected Windows libraries and the environment/math/loader targets: 23/23 selected tests pass, including all 18 pending-exception source/flag cases. Current conventions, whitespace and registration checks were repeated. No fresh Linux/macOS/console execution; in particular, the POSIX SIGFPE branch remains unrun locally. The initial build invocation named a nonexistent math-bits target and stopped before compilation; corrected to the actual guest_math/guest_math_exact targets for the passing build above.
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)Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T02:42:30Z.
Reviewed the overlap with #9296 at head
595dcacdf2db34a283be4716ef7d3ddaf50014ec. Its runtime/test changes concern snprintf/vsnprintf capacity overflow; this PR changes feupdateenv. The reported overlap is two independent additions immediately before### Functionalin docs/dev/debt/libc.md. Neither relies on the other's code or exports, so Depends on remains none. If either merges first, preserve both debt entries when integrating the other; this PR currently merges cleanly into main. No runtime change is needed for this overlap.Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T18:17:08Z.
Review: APPROVED
Checked against main
a6646f8464and FreeBSD amd64 fenv.c / x86 fenv.h @d106002967:feupdateenv: savefnstsw|stmxcsr,fesetenv(fldenv+ldmxcsr), thenferaiseexcept(fnstenv/OR/fldenv, MXCSR OR,fwait). An unmasked pending x87 exception traps at the samefwait, and masked ones only set flags in both units, as on FreeBSD.GuestFloatingPointEnvironment(28-byte x87 env + MXCSR at 0x1c) with rawfnstenv/fldenv, so MinGW's hostfenv_tandFE_DFL_ENVsentinel never come into play. Good.fxsaveMXCSR_MASK read (dword 7, 0xFFBF fallback) is the right offset.YXQ4gXamCrYhashes fromfeupdateenv, and the branch still merges cleanly into current main.fegetenv/fe* entries at the top of "Unknown function info" than as a separate paragraph above### Functional.linux/windowslibs CI jobs were skipped on this PR, so the POSIXSIGFPEside of the new trap tests hasn't run anywhere yet.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.