Repository navigation
feat(libc): export _FDsign/_Dsign like MSVC CRT (PPSA34015) - #6085
Conversation
Absent PPSA34015 libc imports; return the IEEE sign bit as 0x8000/0. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
# Conflicts: # core/libs/prx/libc/CMakeLists.txt
The console's libc passes the value in xmm0: _Dsign (va 0x546f0) stores xmm0 with vmovsd and returns the top 16-bit word & 0x8000; _FDsign (va 0x546a0) does the same with vmovss. Take float/double by value, drop the null-pointer checks, and declare both in libc Api.hpp. The test calls the canonical declarations by value and covers +/-0, +/-1, +/-inf and -NaN.
|
The current PR description is missing the template’s The by-value |
|
Correction: In the previous review (at head should-fix Findings
Freshness Envelope
Cross-PR Ledger
|
ahmadmuj
left a comment
There was a problem hiding this comment.
Reviewed head abbd3bd22ab8 merged onto main f2d874c1fdcc (clean merge). As far as I can tell this is the first Linux run of the by-value head; the earlier Linux runs here were on ffea0b7c (pointer version).
What I ran (WSL2 Ubuntu 24.04, GCC 13.3, Release, BUILD_TESTING=ON):
ctest -R '^guest_(dsign|math|math_exact)$' --repeat until-fail:3: all 3 pass, 3 of 3 rounds.- Red control: main's
Math.cpp/Api.hppwith this test doesn't build ('_FDsign_nid_postfix' was not declared in this scope). objdumpof the builtlibc.prx: value comes from xmm0, nothing is read through rdi, result is the top word & 0x8000 in ax. Same shape as the retail disassembly described above:_FDsign: movd eax,xmm0 ; shr eax,0x10 ; and ax,0x8000 ; ret _Dsign: movq rax,xmm0 ; shr rax,0x30 ; and ax,0x8000 ; ret- Scratch caller against the built
libc.prx(not part of the PR): +/-qNaN, +sNaN, -NaN with payload (0xFFC00123,0xFFF8000000000123), +/-denorm_min, +/-max,0x7FFFFFFF: all as expected, input bits unchanged. tools/check_conventions.py --base origin/main: pass.
Sources checked:
- NIDs: the
tools/nid_names.pyhash gives_FDsign->6ei1eQn2WIcand_Dsign->zvl6nrvd0sE, matching the description. - Wine's msvcrt
_fdsign/_dsign(dlls/msvcrt/math.c) do the same>> 16/>> 48& 0x8000. Returningshort-32768 matches the existing_LDsign(MathExact.cpp:252) and its test. - No other
_Dsign/_FDsignon main, so no duplicate export.
Looks good to me. One small non-blocking nit: docs/dev/REVERSE_ENGINEERING.md ("Citing it") asks for a debt entry when behaviour comes from disassembly. For example, in docs/dev/debt/libc.md: "_Dsign/_FDsign take the value in xmm0 and return the sign bit as 0x8000; read from libc.prx disassembly, not measured on a console."
Not checked: Windows, macOS, the title (no dump here).
What
tools/import_audit.pyon PPSA34015 lists absentlibc.prximports6ei1eQn2WIc(_FDsign) andzvl6nrvd0sE(_Dsign). Match MSVC/Dinkumware: return0x8000when the IEEE sign bit is set, otherwise0. Null pointers throw.Tested
Windows 10, WinLibs GCC 15.2.0,
guest_dsignpasses.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)Made with Cursor