feat(libkernel): implement pthread_setaffinity_np #4514
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4514"
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 kallmek3nny on 2026-10-12T14:05:15Z.
What
Carries screamm's standalone
pthread_setaffinity_npcommit from #4463 unchanged, preserving the original commit and authorship.The implementation follows the FreeBSD-style affinity behavior described and tested in #4463: validate another thread before the cpuset size, require the 32-byte guest
cpuset_t, reject a null set, clip the requested mask tosceKernelGetAvailableCpumask(), reject an empty result, and store the affinity through the existing guest-thread path. The accompanyingguest_available_cpumaskcoverage exercises the caller, another live thread, unavailable bits, invalid sizes/pointers, unknown threads, and joined threads.This addresses the
pthread_setaffinity_nphalf of #4463. Thesys_siglist/sys_nsighalf is already carried separately in #4469.Tested
Not rerun locally in this carry checkout. The original author reports Windows 11 / WinLibs GCC 15.2.0 Release testing with
guest_available_cpumask3/3, the non-GPU suite 607/607,tools/check_conventions.py --base main, andgit diff --checkpassing; details are in #4463.GitHub's PR workflows passed on the unchanged carried commit before the branch sync. The branch now merge-syncs upstream
mainat8fa5cc486687471840d232e18d58dbdb2a68a660while preserving screamm's original commit018524d5295de79e174494286b620a2d8d7d8d30unchanged in history.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T14:06:23Z.
Progress report (
8fa5cc4→ dee2b0e)📈 System libraries: 86.34% (+0.01%, +1 implemented functions)
✅ 1 implemented
pthread_setaffinity_np_nid_postfixImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T14:29:37Z.
I ran the carried commit
018524d52locally, since the PR body says it wasn't rerun. I'd prepared the same carry, so I'll leave it to this PR. Windows 11 (26300), WinLibs GCC 15.2.0, Ninja, Release,BUILD_TESTING=ON, with the commit merged ontomainc6efe068a.Tests
guest_available_cpumask: 3/3.ctest -E '^agc_' -j 4: 533/533. The change doesn't touch AGC, so the GPU tests weren't run.pthread_setaffinity_np; each one makesguest_available_cpumaskfail:sceKernelGetAvailableCpumask();ERANGEsize check;ESRCHlive-thread check.conventions_ci_gate, because my fork runs the oldbuild.ymlwithout file filters. It is not this change.Title. PS5CEMU-HAR (PPSA99360, catalog 3.5.0), relinked with
--windows --trap-sdk-syscall-stubs. Each row adds one change onto the row above:mainunresolved ELF import avvJ3J0H0EY from libkernel.prx(sceKernelJitCreateSharedMemory, #3787)File/srcconflicts withmainresolved by keeping both sides)unresolved ELF import 5KWrg7-ZqvE from libkernel.prx(pthread_setaffinity_np)unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx(swscanf, #4467)unresolved ELF import ELSr5qm4K1M from libSceLibcInternal.prx(__umodti3, #4462)So this PR moves the title past
pthread_setaffinity_nponce #3787 is in. The checklist could sayDepends on: #3787andUnblocks: PPSA99360.sys_siglist/sys_nsig(#4469) are not a stop for this title.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:55Z.
Please rebase onto main and drop the merge commit (
dee2b0e67); branches here carry none. It conflicts now inPthread/include/Pthread.hpp,Pthread/src/Thread.cppand the debt entry, which goes indocs/dev/debt/libkernel.mdsince the split. #3787 has merged, so this no longer waits on anything else.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-13T10:55:47Z.
Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs; basemaind379bfd0with #5025 applied for the title runs (without it currentmaincannot loadlibkernel_sys.prxon Windows, #4877)):dee2b0e6merged ontod379bfd0(two trivial conflicts:mainalready hasGuestThreadIsLive, identical to the PR'sIsLiveGuestThread, so keepmain's and rename the one call; the debt bullet moves todocs/dev/debt/libkernel.mdaftercpuset_getaffinity). The commit is my018524d5unchanged.guest_available_cpumask3/3; suite 687/688 (onlypatched_libraries,main's #4877 failure); conventions andgit diff --checkpass.PS5CEMU-HAR (PPSA99360, relinked with
--trap-sdk-syscall-stubs): beforeFAIL: unresolved ELF import 5KWrg7-ZqvE from libkernel.prx; afterFAIL: unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx(swscanf, #4467). Stacked with #4469 and #4467 the title runs the whole minute atPS5CEMU-HAR | FPS: 59.93 (3483), its launcher logging[ui] frames=3001 avg=16.68 ms.Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:38:37Z.
Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release, on
main3faa9cb40merged with this PR and the other open PRs the catalog titles need; PS5CEMU-HAR (PPSA99360) from its catalog release, converted with--trap-sdk-syscall-stubs(it has a forbidden inline syscall otherwise),eboot.binkept inapp0.tools/import_audit.pylists no absent import for PS5CEMU-HAR and it runs the whole 60 s with no exception.main:mainaddedGuestThreadIsLiveinPthread.hpp/Thread.cpp, which does what this PR'sIsLiveGuestThreaddoes, so a rebase can drop the new helper and usemain's;docs/dev/TechnicalDebt.mdis now split intodocs/dev/debt/<library>.md. For the run above I kept both helpers.AI-assisted (Claude Code).