fix(libc): implement __powidf2 import #2465
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2465"
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 SwazNaj7 on 2026-10-09T22:16:04Z.
What
Implements the Cyberpunk 2077 libc import that called
NotImplemented_nid_no_patch:H+8UBOwfScI(__powidf2): new__powidf2_nid_postfix(double, int)incore/libs/prx/libc/src/Math.cppusing exponentiation by squaring per the GCC libgcc algorithm (unsigned magnitude soINT_MINis safe, reciprocal for negative exponents);libcCyberUnknown08retyped to(double, int) -> doubleand forwards to it.Ye20uNnlglA(abs) is intentionally left as theNotImplementedstub here; it is covered by still-open #1097, which adds the sameabs_nid_postfix(int)wrapper plus the sameGuestMath.cppchecks.NID hashes and
APS5_EXPORTnames are unchanged. AddsCheckIntegerPowerregression tests tocore/libs/tests/GuestMath.cpp(exact powers,0^0/0^+/-n, negative bases/exponents, near-normal-range bases,INT_MINexponents).Tested
upstream/main(c6e3aa76, no merge commits);git diff --check: clean;mergeable: MERGEABLE.python tools/check_conventions.py --base upstream/main: pass.python tools/nid_names.py --nid H+8UBOwfScI:already-implemented __powidf2;--nid Ye20uNnlglA:rename-ready abs(still a stub, left for #1097).g++ -std=c++20 -fsyntax-onlyonMath.cpp,Export.cpp,GuestMath.cpp: pass (MSYS2 MinGW GCC 16.2.0).Math.cppobject: all 18CheckIntegerPowerassertions pass, plus a 117-case sweep against__builtin_powiwith 0 mismatches (bit-exact).ctest -R guest_math(no Ninja/supported toolchain and submodules uninitialized in this environment); CI needs to be green.Checklist
main;absleft to #1097, no other open PR implements__powidf2NotImplemented_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 adriadam10 on 2026-10-09T22:20:16Z.
Review: CHANGES_REQUESTED
Thanks for the PR. Two things before this can go in:
absoverlaps with #1097, which is still open and adds the sameabs_nid_postfix(int)wrapper plus the sameGuestMath.cppchecks. Please dropabs(theYe20uNnlglAexport change,abs_nid_postfixandCheckAbsoluteValue) from this PR, keep__powidf2, and list #1097 under "Depends on" only if you still need it for the test list; otherwise just leave it out.mainincore/libs/tests/GuestMath.cpp. Please rebase (no merge commits) after the change above.The
__powidf2part looks fine on reading (square-and-multiply,INT_MINhandled via unsigned magnitude, reciprocal for negative exponents). Once rebased, please also runctest -R guest_mathand put the result under "Tested" (it's currently listed as not run); CI will need to be green too.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:44:57Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T22:50:07Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
aa7f1f4d:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).__powidf2implementation inMath.cppandGuestMath.cpptests. Properly exposes software integer exponentiation helper expected by guest LLVM/clang compiler-rt runtimes.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:26:27Z.
Progress report (
a11c8f7→b3845e9)📈 System libraries: 85.82% (+0.01%, +2 implemented, +1 declared functions)
✅ 2 implemented
__powidf2_nid_postfixlibcCyberUnknown08🆕 1 declared as stubs
libcCyberUnknown02Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:09:25Z.
Reopened. Conflict in
core/libs/prx/libc/Export.cpp; can you rebase? Does Cyberpunk 2077 call__powidf2on main? Please post the line where it stops, and run the full build withctest -R guest_math.Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:26:44Z.
Additional platform validation of standalone PR head
aa7f1f4d6e416c700d92bfd28bf62de6d8e1b1d3(2026-10-11):Windows: passed — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release,
BUILD_TESTING=ON.1 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.
Checks:
guest_math.Command after building:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_math$".No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Imported from boykopovar/AnyPS5. Originally posted by SwazNaj7 on 2026-10-11T14:06:03Z.
I've rebased the PR onto the latest
mainto address the conflict incore/libs/prx/libc/Export.cppand pushed the updated branch.This PR implements
__powidf2, which computes a floating-point base raised to an integer exponent. The implementation uses exponentiation by squaring, and the associatedguest_mathtest covers the implementation.Testing and validation: referring to the earlier checks made by Mouhand-Kaddo
aa7f1f4d6e416c700d92bfd28bf62de6d8e1b1d3.guest_mathCTest passed with 0 failures and 0 skips under Windows 11, using WinLibs GCC 15.2.0, CMake 4.3.1, and Ninja in Release mode withBUILD_TESTING=ON.Regarding Cyberpunk 2077: I haven't been able to run the game against this build, so I can't independently confirm whether it calls
__powidf2on the currentmainbranch or provide the exact line where execution stops. I don't want to speculate about the runtime behavior without being able to reproduce it.Could someone with a working build verify the updated branch and check whether Cyberpunk 2077 reaches or calls
__powidf2onmain? If it does, the exact stopping point or relevant log would help confirm the behavior this PR needs to address.Thanks!
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T16:09:29Z.
Review: CHANGES_REQUESTED
Thanks for the rebase. The current head doesn't link when merged onto
main(a11c8f7f7); the rebase resurrected old stubs:core/libs/prx/libc/Export.cppre-addsvsnprintf_s_nid_postfix,vsscanf_s_nid_postfix,_Mtx_destroy_nid_postfix,_Cnd_destroy_nid_postfixand_Iswctype_nid_postfix.mainalready implements them (src/Formatting.cpp,src/Threads.cpp,src/RuneLocale.cpp), solibc.prxfails withmultiple definition of ...for all five.Ye20uNnlglA/libcCyberUnknown02stub.absis already implemented onmain(src/Math.cpp:78, with tests inGuestMath.cpp), so the stub must not come back.docs/dev/TechnicalDebt.md:346adds avsnprintf_s, vsscanf_sline that is false onmain(they are implemented). The_ZSt14_Atomic_assertline is fine, but note the code comment above that function is only moved, not needed; keepmain's comment as is or move it, but not both.Fix: start again from current
upstream/mainand keep only the__powidf2change: theMath.cppfunction, theH+8UBOwfScIexport retyped to(double, int) -> doubleinExport.cpp, and theCheckIntegerPowertest.git diff upstream/main --statshould then show those three files only. The__powidf2algorithm and the tests look right; I'll runguest_mathand the negative check once it builds.As @oneandonlydean asked: please also post the line where Cyberpunk 2077 stops on
mainwithout this change, and the output ofctest -R guest_mathfrom a full build.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:33:19Z.
Closing:
__powidf2is on main since #5174.Reopen if something here is still missing on current main.
Pull request closed