libc: long double libm against the libc.prx bundled with PPSA10122 (SDK 5.00): bits, flags and errno on Windows #22838
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 DerKarussellbremser on 2026-11-18T12:04:16Z.
Where this libc's
long doublemath stands against thelibc.prxa title bundles, measured by running that copy natively on Windows. It is a map in the style of #9707, which did this for the single-precision functions.docs/dev/debt/libc.mdsays ofexpl,sinhl,coshl,tanhl,erflanderfclthat the FreeBSD 11.4.0 source is the only evidence and that they are unverified against a consolelibc.prx; this is that comparison for one build.Method
The module is
sce_module/libc.prxof PPSA10122 01.101.000 (SDK 5.00), from my own dump. A scratch harness that is not in the repository maps its segments, applies its relocations and supplies__error. Every other import traps, and none was reached.Each export was called next to the export with the same NID of this libc (
core/libs/libs/libc.prx,maine524ed000a, WinLibs GCC 15.2.0 r7 UCRT, Release, Windows 11 10.0.26200) on the same 200,000 arguments per function. Half of the arguments are random 80-bit patterns with a canonical integer bit, half are random significands with exponents from 2^-15 to 2^16. Two-argument functions draw both arguments independently.Each call starts with the x87 control word set (0x37f for 64-bit precision, 0x27f for 53-bit) and both exception registers cleared. A call is counted once, in the first column that applies: the result bits differ (two NaNs count as equal), else the union of the x87 and MXCSR exception flags differs, else
errnodiffers.Result
Of 43 functions, 24 agree on every argument at both precisions, in bits, flags and
errno:sinl,cosl,tanl,asinl,acosl,atanl,asinhl,acoshl,atanhl,exp2l,logl,log2l,log10l,log1pl,cbrtl,rintl,nearbyintl,logbl,fabsl,atan2l,hypotl,fmaxl,fminl,copysignl.The others:
errnoonlyerrnoonlysinhlcoshltanhlexplexpm1lsqrtlerflerfcllgammaltgammalceillfloorltrunclroundlpowlfmodlremainderlfdimlnextafterlis exported by the module (0x48920) and not by this libc; #6295 is open for it.What the differences are
expl,sinhl,coshl,tanhl,expm1l,erfl,erfcl. This libc follows FreeBSD msun 11.4.0 here (#18525, #19342, #19346). The module does not:expl(0x47430) calls_LExp.sinhl(0x504e0) andcoshl(0x45ab0) are 11-instruction wrappers around_LSinhand_LCosh.tanhl(0x51660) andexpm1l(0x474c0) callexpl.erfl(0x46f60) anderfcl(0x47180) call_LExpand_LPoly.Where the results differ it is in the last bits, for example
expl(0x3ffe:cce56ce05f6cdac4): the module returns0x4000:8e7cf75f6546c30b, this libc...c30a. Two differences outside the result bits, seen forexplandsinhl:ERANGE; this libc leaveserrnounchanged.explunderflows to +0 the module raises no flag; this libc raisesFE_UNDERFLOWandFE_INEXACT. For arguments thatsinhlandtanhlreturn unchanged, and wheretanhlsaturates to ±1, the module raises no flag and this libc raisesFE_INEXACT.I did not look at which side stores what in the
errnocolumn ofcoshl,expm1l,erfclandpowl.powl,lgammal,tgammal. These return the host library's results in this libc. In the modulepowl(0x4c950) is a 12-instruction wrapper around an internal routine at 0x4bf70, whichlgammal(0x4b830) also calls, as does the routine at 0x4bcf0 thatlgammalandtgammal(0x526f0) share.I have a rewrite of
tgammaland of 0x4bcf0 that gives the module's bits, flags anderrnoon 400,000 arguments at each of 64-, 53- and 24-bit precision. It still calls the module's own helpers, so it is not a PR yet; the routine at 0x4bf70 has to be written first, and that would coverpowlas well. I am working on it.Flags only.
sqrtlof a negative finite argument: both return the default NaN and storeEDOM. The module raisesFE_INVALIDonly. This libc raisesFE_INEXACT, withFE_OVERFLOWorFE_UNDERFLOWfor large or small magnitudes, and notFE_INVALID.roundlof an integral argument such as0x4c9b:9333ddceb4331e0a: the module raisesFE_INEXACT, this libc raises nothing.fdimlreturning +0: the module raisesFE_INEXACT, this libc raises nothing. I looked at four such cases, not at all of them.I did not look at the small counts (
ceill,floorl,truncl,fmodl,remainderl, and the 21 and 10 result differences ofroundlandfmodlat 53 bits).Not covered
libSceLibcInternaland a console were not compared.AI-assisted: yes (Claude Code)