Repository navigation
feat(libSceLibcInternal): implement the Dinkumware extended-precision helpers - #16237
Open
Ducengarth wants to merge 3 commits into
Open
Ducengarth wants to merge 3 commits into
Ducengarth wants to merge 3 commits into
Conversation
… helpers Implement _Dtento, _FDtento, _LDtento, the float _FXp_* helpers other than _FXp_getw and the twelve long double _LXp_* helpers after Dinkumware V6.00 as shipped with Visual C++ 2013. _LXp_getw and the reads inside _Dtento follow the console's _FXp_getw. Record the unverified console behaviour and the differences from V6.00 as debt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
Progress report (6bf3a19 → bfbd4f9)📈 System libraries: 29.91% (+0.06%, +26 implemented functions) ✅ 26 implemented
Changed libraries (implemented exports)
|
…xtended-precision # Conflicts: # docs/dev/debt/libSceLibcInternal.md
…/libcinternal-extended-precision # Conflicts: # docs/dev/debt/libSceLibcInternal.md
This branch has not been deployed
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 26 Dinkumware extended-precision helpers in
libSceLibcInternal, replacing their parameterless throwing placeholders inExport.cpp:_Dtento,_FDtento,_LDtento:*value * 10^power, wherevaluepoints to a three-word extended-precision accumulator that is updated in place. On overflow or underflow they set the guesterrnotoERANGE(34) and OR 1 into*errorwhen it is not null._FXp_addh,_FXp_addx,_FXp_invx,_FXp_ldexpx,_FXp_movx,_FXp_mulh,_FXp_mulx,_FXp_setn,_FXp_setw,_FXp_sqrtx,_FXp_subx(float)._LXp_addh,_LXp_addx,_LXp_getw,_LXp_invx,_LXp_ldexpx,_LXp_movx,_LXp_mulh,_LXp_mulx,_LXp_setn,_LXp_setw,_LXp_sqrtx,_LXp_subx(long double).An extended-precision value is an array of words in decreasing magnitude, each holding at most half the significand (12 bits for
float, 26 fordouble, 32 forlong double), ended by a zero word. One template in the newExtendedPrecision.cppserves all three types.Source: Dinkumware V6.00 as shipped with Visual C++ 2013 (
xxxprec.h,xxxdtent.h, prototypes inxmath.h), the reference the debt file already uses for_Thrd_sleep. The code is written from that algorithm, not copied.longarguments arestd::int64_t, as in the PS5 ABI. Differences from V6.00, all recorded indocs/dev/debt/libSceLibcInternal.md:_LXp_getwand the reads inside_Dtentofollow the console's_FXp_getwfrom feat(libSceLibcInternal): answer _Daysto, _FXp_getw and _Isdst as firmware 13.42 does #14945, read from firmware 13.42: they add the fourth word when there are at least four, instead of V6.00's sticky bit. This also means the console runs a later revision than V6.00, so other helpers may differ in details._Xp_mulxmultiplier reads only that word (same result). A word count below 1 does nothing in_Xp_movx,_Xp_addh,_Xp_invxand_Xp_sqrtx, where V6.00 callsmemcpywith a negative size for a finiteinvxorsqrtxargument. A_Dtentopower ofLONG_MINunderflows instead of looping onn = -n. The_Xp_addhcarry bit count is not truncated toshort.Scope:
_FXp_getwis already inmain(#14945). Thedouble_Xp_*exports are still unnamed placeholders, and #15777 names them; they can follow once it merges._FAtan,_FSincos,_FTan,_FTgamma,_FLogpoly,_FQuad,_FQuadphand their_Landdoubleversions still throw: no source I found gives their signatures or code.No title's trace or disassembly was used, and no export was measured on a PS5.
pr_overlapreports no other pull request with the same exports or new files, only line conflicts: #15767 adds other math declarations between these inMathInternals.hppand next to the_Dtentostubs inExport.cpp, #13881 and #14085 edit neighbouring debt lines, and #15665 and my #16146 add a test block at the same place inCMakeLists.txt. Whichever merges second resolves them; I will rebase this one as needed. Nine pull requests that conflict withmaincould not be compared by the tool (#5021, #13486, #13778, #13782, #14212, #14664, #14936, #15581, #15899); none of their diffs adds any of these 26 names.Tested
Windows 11, MinGW-w64 GCC (WinLibs), Release build. No title or homebrew, and not built on Linux.
guest_libc_internal_extended_precision(new) passes, and passed 3 more runs in a row. It calls every one of the 26 exports, and_FXp_getwfrommain, and checks:setwsplits 20000 random floats into two exact half-width words, plus zero, one word, infinity, no room and subnormals.setnholds 32-bit integers exactly and rounds the quotient by 10000 tofloatfirst for wider ones.addhkeeps exact sums of half-precision addends in decreasing words, and handles cancellation, infinity,Inf - Inf(FE_INVALID), NaN and a full array.mulhandmulxkeep exact or six-word products.movx,ldexpx,addxandsubxbehave as above, and so doinvxandsqrtx, within 2^-40 and 2^-36 of the exact result, read back within one ulp.sqrtxalso covers negative values, -0 and ±infinity._Dtentogives correctly rounded powers of ten from 10^-22 to 10^22, the exact one-tenth words for each type, overflow, underflow, a nullerrorpointer and a power ofINT64_MIN._LXp_getwadds a fourth word where V6.00's sticky bit would round differently.getwignore the fourth word, makingmulhdrop the low half of a partial product, or changing the last word of thelong doubleone-tenth table each makes the test fail with the matching message.guest_libc_internal_firmware_answers,guest_libc_internal_aligned_new,guest_libc_internal_exception_destructors,guest_libc_internal_mtx,guest_libc_internal_padandguest_statvfspass. The full suite was not run.objdump -ponlibSceLibcInternal.prxlists all 26 names.python3 tools/check_conventions.py --base upstream/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