Skip to content

feat(libc): export guest hardware concurrency hint - #1814

Closed
Prophet069 wants to merge 1 commit into
boykopovar:mainfrom
Prophet069:pr/libc-hardware-concurrency
Closed

Prophet069 wants to merge 1 commit into
boykopovar:mainfrom
Prophet069:pr/libc-hardware-concurrency

Conversation

@Prophet069

Copy link
Copy Markdown
Contributor

What

Implements std::__sce_v2::_Thrd_hardware_concurrency() in libc with NID dt3C+gjXHKk.

The export has the signature unsigned int () noexcept, uses extern "C", APS5_VABI and the existing _nid_postfix export mechanism, and returns std::thread::hardware_concurrency() unchanged. This preserves the host's hardware-thread hint, including zero when unavailable, without inventing a fallback count. The wrapper adds no shared mutable state or caching.

The return type and no-argument signature agree with Microsoft STL's declaration. Zero follows the standard hardware-concurrency contract. The NID agrees with the existing PS5 symbol database.

Based on main at 4b6ab6bb7371869f85837ff824f409b49f1e8081. A search of all 390 open PRs found no matching implementation. This change is independent of #1806 and contains no mathematics exports or tests.

Tested

Windows x86-64, MinGW GCC 15.2.0, CMake/Ninja Release with BUILD_TESTING=ON:

  • Configured the complete project using existing source dependencies and the existing FFmpeg build. Built only libc, guest_hardware_concurrency_tests, guest_thread_callback_abi_tests, guest_demangle_tests and nid_patcher, with at most four build jobs.
  • Ran guest_hardware_concurrency, guest_thread_callback_abi and guest_demangle through CTest, each three times: all passed, with every run below 0.13 seconds.
  • The new runtime test compares the guest return with the native C++ hint, accepts zero, and checks repeated calls from two concurrent threads (128 queries each). Compile-time assertions verify the 32-bit unsigned result and noexcept declaration. No host returning zero was available; that path was reviewed, not separately simulated.
  • Inspected the compiled ABI bridge: the native return register is preserved without conversion or clamping. Patched the freshly built libc.prx with nid_patcher and verified the actual NID export using import_audit.read_exports and nid_names.compute_nid.
  • check_test_registration.py passed: 427 test targets, only the three previously documented exclusions, no new unregistered tests.
  • git diff --check and tools/check_conventions.py --base origin/main passed; the conventions check also validated this PR title and description.

Linux compatibility was reviewed at source level: the implementation and test use standard C++ facilities, and APS5_VABI selects the native ABI on Linux. Linux was not built or executed locally because no usable Linux environment is installed; Linux CI remains required. No full-project build, game or homebrew execution was performed.

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 (no new comments)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (no new stubs)
  • 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 added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, OpenAI Codex assisted with implementation, test preparation and local validation. The PR author remains responsible for every submitted line.

@github-actions

github-actions Bot commented Oct 9, 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
#2019 core/libs/prx/libc/CMakeLists.txt L48
#2058 core/libs/prx/libc/CMakeLists.txt L48
#2059 core/libs/prx/libc/CMakeLists.txt L48
#2060 core/libs/prx/libc/CMakeLists.txt L48

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Same as #1806, for _Thrd_hardware_concurrency.

ycbuzi pushed a commit to ycbuzi/AnyPS5 that referenced this pull request Oct 10, 2026
…cy hint

Harvested from upstream (closed unmerged); library completion 2922/3294 -> 2923/3295. Additive conflicts resolved by keeping both sides: core/libs/prx/libc/CMakeLists.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011krDVCnnMQPaEFEqCDnKmA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants