Skip to content

feat(libkernel_sys): implement the scePthread scope, atfork and setconcurrency forms - #9141

Merged
oneandonlydean merged 9 commits into
boykopovar:mainfrom
MarrasFederico:feat/kernel-sys-pthread-scope-atfork
Oct 23, 2026
Merged

oneandonlydean merged 9 commits into
boykopovar:mainfrom
MarrasFederico:feat/kernel-sys-pthread-scope-atfork

Conversation

@MarrasFederico

@MarrasFederico MarrasFederico commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

scePthreadAttrGetscope, scePthreadAttrSetscope, scePthreadAtfork and scePthreadSetconcurrency were libkernel_sys discovery stubs that threw. libkernel already implements their POSIX forms (pthread_attr_getscope, pthread_attr_setscope, pthread_atfork, pthread_setconcurrency). The four sce forms now call them and turn a POSIX error into 0x80020000 | errno, as #8987 does for the barrier, cpuclockid and concurrency forms; this builds on its SceResult helper.

shadPS4 exports scePthreadAttrGetscope (+7B2AEKKns8) as ORBIS(posix_pthread_attr_getscope), the same wrapping. It has no export for the other three. Their names and NIDs (YdZfEZfRnPk, i1kREW2pchs, gdnv6wF6hwI) are in the symbol database, and their signatures follow the same POSIX forms.

What they do is libkernel's behaviour:

  • Scope: 0 (process) or 2 (system), with system as the default; any other scope and null pointers return EINVAL.
  • Concurrency: a negative level returns EINVAL; otherwise the level is stored and read back by scePthreadGetconcurrency.
  • Atfork: handlers are recorded in order, null handlers included, since no process forks.

The debt entry records that none of this is measured on a console.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Simone and others added 3 commits October 21, 2026 10:40
…currency and msync forms

Forward scePthreadBarrier*, scePthreadBarrierattr*, scePthreadGetcpuclockid,
scePthreadGetconcurrency and sceKernelMsync to libkernel's POSIX
implementations and return POSIX errors as SCE kernel errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (0a0ed72 → de981a2)

📈 System libraries: 45.86% (+0.03%, +4 implemented functions)

✅ 4 implemented
Library Name
libkernel_sys scePthreadAtfork
libkernel_sys scePthreadAttrGetscope
libkernel_sys scePthreadAttrSetscope
libkernel_sys scePthreadSetconcurrency

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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/CMakeLists.txt
PR 6044 core/libs/CMakeLists.txt
PR 6525 docs/dev/debt/libkernel_sys.md
PR 7201 core/libs/CMakeLists.txt
PR 7275 core/libs/CMakeLists.txt
PR 7622 core/libs/CMakeLists.txt
PR 7780 core/libs/CMakeLists.txt
PR 8285 core/libs/CMakeLists.txt
PR 8457 docs/dev/debt/libkernel_sys.md
PR 8650 core/libs/CMakeLists.txt
PR 8658 core/libs/CMakeLists.txt
PR 8701 docs/dev/debt/libkernel_sys.md
PR 9019 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9063 core/libs/CMakeLists.txt
PR 9097 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9103 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9161 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9162 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9172 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9173 core/libs/CMakeLists.txt
PR 9187 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9284 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9293 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9297 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9302 core/libs/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9442 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9571 core/libs/CMakeLists.txt
PR 9693 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9802 core/libs/CMakeLists.txt
PR 9896 core/libs/CMakeLists.txt
PR 9924 core/libs/CMakeLists.txt
PR 9933 core/libs/CMakeLists.txt
PR 9942 core/libs/CMakeLists.txt
PR 10060 docs/dev/debt/libkernel_sys.md

@ycbuzi

ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Windows run of d6b3846 merged onto main 0c6a5bd (a3706ed2cf, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libkernel_sys, guest_kernel_sys_barrier_tests and guest_kernel_sys_pthread_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_kernel_sys_barrier and guest_kernel_sys_pthread: both pass on both repeats. Not run: a title.

…read-scope-atfork

# Conflicts:
#	core/libs/CMakeLists.txt
#	core/libs/prx/libkernel_sys/Export.Discovery.cpp
#	docs/dev/debt/libkernel_sys.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@MarrasFederico the four new sce forms (scePthreadAttrGetscope, scePthreadAttrSetscope, scePthreadAtfork, scePthreadSetconcurrency) look right to me: each one calls the libkernel POSIX form and goes through #8987's SceResult, and guest_kernel_sys_pthread covers them.

One thing blocks it. This branch carries an older copy of #8987 (6131ec265d), but #8987 was rebased since then and is now 106e73669d. The new head also adds the 0x80000000 count check to GuestKernelSysBarrier.cpp and orders the registration after guest_kernel_sys_thread_defaults. The two branches now conflict in core/libs/CMakeLists.txt, Export.Discovery.cpp, GuestKernelSysBarrier.cpp and docs/dev/debt/libkernel_sys.md, whichever lands first. If this one landed first, it would also drop #8987's new check.

Could you rebase onto #8987's current head (106e73669d), so this PR only adds your commit on top of it? Nothing else needs to change.

@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@oneandonlydean done. The branch now carries #8987's current head 106e73669d and only my commit on top. I can't force-push from here, so I didn't rebase; I rebuilt the commit with git cherry-pick onto 106e73669d, merged current main, and gave this branch exactly that tree with a merge commit (git diff between the two is empty).

@MarcZX10 MarcZX10 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 exact head e8f8e59. The dependent #8987 changes are retained, and the checklist declares that dependency. The four new SCE forms delegate to the existing POSIX providers with SCE errno mapping; tests cover scope state/error preservation, concurrency, and atfork registration order. Local diff whitespace, conventions, registration, and current-main checks pass. The PR reports a Linux full build/focused tests, and an independent Windows build plus repeated barrier/pthread runs; I did not execute those binaries locally. Hosted product jobs are skipped by policy, and console behavior remains documented as unmeasured.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 513ca7e into boykopovar:main Oct 23, 2026
12 checks passed
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.

4 participants