Repository navigation
feat(libc): implement rint and lrint families - #2235
Closed
obojeoboje wants to merge 1 commit into
Closed
obojeoboje wants to merge 1 commit into
obojeoboje wants to merge 1 commit into
Conversation
This was referenced Oct 9, 2026
This was referenced Oct 9, 2026
Collaborator
|
Same as #2217, for the |
ycbuzi
pushed a commit
to ycbuzi/AnyPS5
that referenced
this pull request
Oct 10, 2026
Harvested from upstream (closed unmerged); library completion 2904/3278 -> 2913/3287. Additive conflicts resolved by keeping both sides: core/libs/prx/libc/CMakeLists.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011krDVCnnMQPaEFEqCDnKmA
This was referenced Oct 19, 2026
oneandonlydean
pushed a commit
that referenced
this pull request
Oct 20, 2026
MathExact.cpp was built without -frounding-math, so GCC compiled std::rint as an add and subtract of 2^52 on the magnitude, which is exact only when rounding to nearest: under FE_DOWNWARD rint(-1.5) returned -1 and rintf(-1.5f) -1, where C and FreeBSD's libm give -2. lrint and llrint were right: they call the host libm's llrint, which honours the mode. MathExact.cpp now builds with -frounding-math. GuestMathExact checks rint, rintf, rintl, lrint and llrint of -1.5 and 1.5 in all four rounding modes and that the mode is unchanged. The failure was first caught by the rounding test of #2235 (Привалов Александр Владимирович). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implement nine libc exports:
rint,rintf,rintl,lrint,lrintf,lrintl,llrint,llrintf, andllrintl.The functions honor the active floating-point rounding mode and preserve floating-point exception behavior. Guest
longresults use the hostllrintoverloads to retain 64-bit values on Windows. Extended-precision overloads retain the guest x87long doublerepresentation. Compile only this translation unit with-frounding-math; without it GCC's optimizedrintgives incorrect negative results under directed rounding.Behavior references: FreeBSD rint(3) and lrint(3). Export names are present in the shadPS4 aerolib table.
The progress scanner changes from 2578/3044 (84.69%) to 2587/3053 (84.74%). These are newly declared exports, so both counts grow.
Tested
Windows, WinLibs GCC 15.2, Release build with testing enabled. No game tested.
libstarget passed.guest_video_out_wqhd_detection_no_vulkan), zero failures; 37.64 seconds total.FE_INEXACT, invalid integer conversions (FE_INVALID), results beyond 32 bits, integer boundaries, and extended precision beyond double. Invalid-conversion return values are deliberately not asserted because they are unspecified.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)