Skip to content

feat(libc): export _FDsign/_Dsign like MSVC CRT (PPSA34015) - #6085

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
notaxeltv:feat/libc-dsign-ppsa34015
Nov 2, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
notaxeltv:feat/libc-dsign-ppsa34015

Conversation

@notaxeltv

Copy link
Copy Markdown
Contributor

What

tools/import_audit.py on PPSA34015 lists absent libc.prx imports 6ei1eQn2WIc (_FDsign) and zvl6nrvd0sE (_Dsign). Match MSVC/Dinkumware: return 0x8000 when the IEEE sign bit is set, otherwise 0. Null pointers throw.

Tested

Windows 10, WinLibs GCC 15.2.0, guest_dsign passes. tools/check_conventions.py --base upstream/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA34015 (absent libc imports)
  • GPUs tested: n/a
  • AI-assisted: yes

Made with Cursor

Absent PPSA34015 libc imports; return the IEEE sign bit as 0x8000/0.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Progress report (5c9837b → abbd3bd)

📈 System libraries: 25.87% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc _Dsign_nid_postfix
libc _FDsign_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1484/1500 (98.93%) 1486/1502 (98.93%) +0.0014%

This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9798 core/libs/prx/libc/CMakeLists.txt L552

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.

Pull request Shared files not compared
PR 5021 core/libs/prx/libc/CMakeLists.txt
PR 6295 core/libs/prx/libc/src/Math.cpp
PR 7081 core/libs/prx/libc/CMakeLists.txt
PR 7447 core/libs/prx/libc/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
PR 8150 core/libs/prx/libc/CMakeLists.txt
PR 8965 core/libs/prx/libc/CMakeLists.txt
PR 9929 core/libs/prx/libc/CMakeLists.txt
PR 11625 core/libs/prx/libc/CMakeLists.txt
PR 11831 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp

# 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.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 1, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

The current PR description is missing the template’s Fixes: checklist line. Please add - [x] Fixes: none, or name the issue if this closes one.

The by-value _FDsign / _Dsign fix is now in the branch, so please also remove the obsolete “Null pointers throw” sentence from the description. The functions take float and double values now.

@fogydes

fogydes commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Correction: In the previous review (at head ffea0b7), a merge conflict in core/libs/prx/libc/CMakeLists.txt and stale base (14,142 behind) required rebase. The updated head abbd3bd incorporates origin/main cleanly (git merge-tree exits 0, clean tree 7c3db23886fe40b93258d0d016dc8c783d44ab40) and switches argument passing to pass-by-value in xmm0.

should-fix

Findings

  1. [verified] Branch freshness & mergeability: The previous merge conflict in core/libs/prx/libc/CMakeLists.txt has been cleanly resolved. git merge-tree --write-tree origin/main abbd3bd22ab819f1099d638a566295cd8db4fff2 exits with code 0 (clean tree 7c3db23886fe40b93258d0d016dc8c783d44ab40). The branch is 187 commits behind origin/main.
  2. [verified] Conventions: python tools/check_conventions.py --base c674f8c14da93df7a6b37657117ca3f58357477f passed cleanly in an isolated scratch worktree with 0 errors and 0 warnings.
  3. [verified] Linear history / commit conventions: Commit a008328d28d is a non-conventional merge commit (Merge main into feat/libc-dsign-ppsa34015). Repository conventions favor clean rebase / linear history.
  4. [read-only] PR title convention: The PR title feat(libc): export _FDsign/_Dsign like MSVC CRT (PPSA34015) appends title ID (PPSA34015) and does not match the commit subject. Per repository conventions, title IDs belong in the Unblocks: PPSA34015 line rather than the PR title.
  5. [read-only] PR template checklist: The checklist is missing the mandatory - [ ] Fixes: none (or issue number) line from .github/pull_request_template.md, as requested by maintainer @oneandonlydean.
  6. [read-only] PR description accuracy: The description states "Null pointers throw", which was true for the earlier pointer-based implementation but is obsolete now that commit abbd3bd passes arguments by value.
  7. [author-reported] Test claim: Author and collaborator @oneandonlydean report guest_dsign passes with the new by-value signatures; test execution not independently run in this review session.

Freshness Envelope

  • Head SHA: abbd3bd22ab819f1099d638a566295cd8db4fff2
  • Base SHA: c674f8c14da93df7a6b37657117ca3f58357477f
  • Commits behind origin/main: 187
  • git merge-tree with origin/main: exit 0 (clean tree 7c3db23886fe40b93258d0d016dc8c783d44ab40)

Cross-PR Ledger

  • PR feat(libc): implement C11 timespec_get (PPSA34015) #6084 (feat(libc): implement C11 timespec_get (PPSA34015)): touches shared files core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libc/include/Api.hpp. Pairwise git merge-tree between their heads exits 0 (clean tree); both PRs can merge together without conflict.

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 1, 2026

@ahmadmuj ahmadmuj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.hpp with this test doesn't build ('_FDsign_nid_postfix' was not declared in this scope).
  • objdump of the built libc.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.py hash gives _FDsign -> 6ei1eQn2WIc and _Dsign -> zvl6nrvd0sE, matching the description.
  • Wine's msvcrt _fdsign/_dsign (dlls/msvcrt/math.c) do the same >> 16 / >> 48 & 0x8000. Returning short -32768 matches the existing _LDsign (MathExact.cpp:252) and its test.
  • No other _Dsign/_FDsign on 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).

@oneandonlydean
oneandonlydean merged commit 848c2ad into boykopovar:main Nov 2, 2026
18 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build libc unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants