Repository navigation
feat(libc): implement __powidf2 and _WStoul - #1980
overlordxrz-source wants to merge 1 commit into
Conversation
H+8UBOwfScI and JhVR7D4Ax6Y were throwing libcCyberUnknown08/09 stubs. They are the NIDs of __powidf2 and _WStoul. __powidf2 is compiler-rt's square and multiply, so results match the guest's own libc bit for bit, including negative exponents and INT_MIN. _WStoul is the Dinkumware helper behind wcstoul and forwards to the existing 16-bit wcstoul export.
MarcZX10
left a comment
There was a problem hiding this comment.
The implementation looks technically sound: __powidf2 matches LLVM compiler-rt’s square-and-multiply routine, and _WStoul forwards to the 16-bit guest wcstoul; 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-main NotImplemented stop 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.
|
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 |
|
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.
|
|
Closing, as you suggested above. Reopen with the |
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 feat(libs): implement font, libc, libkernel and misc prx stubs #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)