feat(libc): implement __powidf2 and _WStoul #1980
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1980"
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 overlordxrz-source on 2026-10-09T03:41:24Z.
What
Cyberpunk 2077 (PPSA04029) imports two
libcfunctions that are still throwing stubs onmain,libcCyberUnknown08andlibcCyberUnknown09.tools/nid_names.pyresolves their NIDs:H+8UBOwfScI__powidf2JhVR7D4Ax6Y_WStoulBoth NIDs are in the PPSA04029 import list attached to #266. None of the other import lists in #267 to #272 contain them.
__powidf2(double, int)is the compiler-rt builtin that clang emits for__builtin_powi. This is its square-and-multiply loop, so it returns the same bits as the guest's own copy. It differs frompowand from multiplyingntimes, for example1.1^13and-1.7^-13. Negative exponents return1/r, andINT_MINworks._WStoul(const wchar_t*, wchar_t**, int)is the Dinkumware function behindwcstoul. It forwards to the existingwcstoulexport, which already reads 16-bit guestwchar_tand returns a 64-bitunsigned longon every host. Hostwcstoulwould read 32-bit units on Linux.The stubs are removed from
Export.cpp._WStoulsits where the two stubs were, next to the existingstd_execute_onceforwarder. That keeps the hunk apart from #1952's deletions in the same file, so the two PRs merge cleanly in either order (checked withgit merge-tree).Not included:
CyXs2l-1kNA(_Iswctype, stub 07). Its second argument indexes Dinkumware's class table, and only index 9 (space) is known from the disassembly quoted in #492. The other indices aren't confirmed, so it keeps throwing. #1498 also changes these stubs as part of its omnibus change and conflicts with this PR inExport.cpp. Its_Iswctypetreats the argument as a bitmask.Log
I don't own Cyberpunk 2077, so I can't paste a line where PPSA04029 stops on
main. I found no stop line for these NIDs in any issue or PR. The evidence is the import list in #266. If someone with the title can post theNotImplementedline forH+8UBOwfScIorJhVR7D4Ax6Yfrommain, I'll add it here.Tested
aarch64 Debian 13 host. The full project can't be built here because it needs x86-64.
core/libs/tests/GuestNumericHelpers.cpp(guest_numeric_helpers), linked natively againstMath.cpp,Strings.cppandExport.cpp, passes 30 of 30 runs and also passes with UBSan. It compares__powidf2bit patterns with an independent IEEE double reference: square-and-multiply cases that differ frompow, negative exponents,NaN^0,±0to negative powers,INT_MINandINT_MAX._WStoulchecks cover bases 0, 10, 16 and 36, wrapping of negative values, the 64-bit maximum, overflow toULONG_MAXwithERANGE, a non-ASCII digit, no conversion and a null end pointer.Math.cpp,Export.cppand the test compile for x86_64-linux-gnu and x86_64-windows-gnu with-Wall -Wextra(Zig 0.17, clang 22). The only warning is the existing-Wreturn-type-c-linkagefromGeneral.hpp.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main. The one other open PR that changes these functions is #1498, which also changes these stubs as part of a larger change; see WhatNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T03:41:44Z.
Progress report (
f145139→a8614c7)📈 System libraries: 84.83% (+0.07%, +2 implemented, -2 removed functions)
✅ 2 implemented
_WStoul_nid_postfix__powidf2_nid_postfix🗑️ 2 removed
libcCyberUnknown08libcCyberUnknown09Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:13:37Z.
Review: CHANGES_REQUESTED
The implementation looks technically sound:
__powidf2matches LLVM compiler-rt’s square-and-multiply routine, and_WStoulforwards to the 16-bit guestwcstoul; the updated Linux/Windows and conventions checks pass. I cannot approve yet because the PR says the only evidence is the import list and that no current-mainNotImplementedstop line was found. CONTRIBUTING.md explicitly says an import list alone does not show a title reaches the export and asks for a reproduced failure or a concrete project need with its limits. Please add the current-main runtime evidence, or explain a demonstrated need that meets that rule.Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-09T04:54:53Z.
Thanks for the review. I looked for runtime evidence and found none. No AnyPS5, KytyPS5 or shadPS4 issue or log has a line where a title calls
H+8UBOwfScIorJhVR7D4Ax6Y, and the #358 liveness pass on PPSA04029 marked neighbouring stubs as live but left these two without a note. There's also a reason to doubt they're reached at all: Cyberpunk's PPSA03974 build ships its ownsce_module/libc.prx(KytyPS5#182 log:Loading: …[PPSA03974]\sce_module\libc.prx), and since7103f390a title's own imports bind to its guest modules first. I'm converting this to a draft, and I'll mark it ready only with a current-main… not implementedline from a title, or close it.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T05:35:05Z.
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.
main)wcstoul_nid_postfixImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:56:51Z.
Closing, as you suggested above. Reopen with the
not implementedline from main if a title turns one up.Pull request closed