Repository navigation
feat(libkernel): implement pthread spinlocks and relative condition wait - #3689
Merged
adriadam10 merged 2 commits intoOct 11, 2026
Merged
Conversation
Progress report (df64fa9 → 774f218)📈 System libraries: 85.96% (+0.02%, +6 implemented functions) ✅ 6 implemented
|
9 tasks done
This was referenced Oct 11, 2026
Add pthread_spin_init (ZMn3clnAGBA), pthread_spin_destroy (IJIggoPZExk), pthread_spin_lock (pw+70ClLYlY), pthread_spin_trylock (rCTGkBIHfPY) and pthread_spin_unlock (LEfMMCT+SlM). The NIDs were computed with tools/nid_names.py and match aerolib.csv. libkernel has no scePthreadSpin* twin in aerolib, so the calls are implemented directly, like the barrier. Titles: Porpoise PPSA99764 and RetroArch PPSA99169 import pthread_spin_lock. Predicted from relink registry order, not observed: after pthread_cond_reltimedwait_np, Porpoise stops with "FAIL: unresolved ELF import pw+70ClLYlY from libkernel.prx" (registry index 387; RetroArch index 493). No call site is resolved in the registry. Behaviour follows FreeBSD 11.4 libthr thr_pspinlock.c and thr_umtx.h (8c639945a44588f6cfdddfb057bb5aad88735da0). The guest pthread_spinlock_t holds a pointer to an allocated lock. EINVAL for a null or destroyed lock and for a pshared other than PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED, EBUSY from trylock while any thread holds the lock, EPERM from unlock by a thread that does not hold it. libthr spins forever when the holder locks again; that call throws here. A shared lock is allocated like a private one, since guest code runs in one process. Recorded in TechnicalDebt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 13ebf7f)
Add pthread_cond_reltimedwait_np (K953PF5u6Pc; computed with tools/nid_names.py and matching aerolib.csv) as scePthreadCondTimedwait with POSIX error numbers: ETIMEDOUT when the relative timeout expires, EPERM when the caller does not hold the mutex, and the mutex held again on return in every waiting case. Titles: Porpoise PPSA99764 and RetroArch PPSA99169 import it. Predicted from relink registry order, not observed: Porpoise stops with "FAIL: unresolved ELF import K953PF5u6Pc from libkernel.prx" (registry index 384; RetroArch index 490). No call site is resolved in the registry. The third argument is a relative timeout in microseconds, not a struct timespec. FreeBSD 11.4 libthr (8c639945a44588f6cfdddfb057bb5aad88735da0) has no such function. shadPS4 (3a9f57265d28975658f1ca941daa5c879c7a74bd, src/core/libraries/kernel/threads/condvar.cpp:229-234, 445, 467-468) registers posix_pthread_cond_reltimedwait_np(cond, mutex, u64 usec) for this NID and the same function for scePthreadCondTimedwait (BmMjYxmew1w), whose microsecond argument this repository already implements. The width follows the SCE twin's 32-bit SceKernelUseconds, as sem_reltimedwait_np does, not shadPS4's u64. There is no timespec to validate, so no EINVAL case. Recorded in TechnicalDebt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit c86ec84)
Collaborator
|
Rebased onto current main: the only conflict was the |
adriadam10
force-pushed
the
codex/libkernel-spin-reltimedwait-3554
branch
from
October 11, 2026 21:56
00e9aad to
774f218
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implement the POSIX pthread spinlock family and
pthread_cond_reltimedwait_npin libkernel, carrying David's two commits from issue #3554 with his commit authorship preserved.pthread_cond_reltimedwait_npforwards the relative timeout toscePthreadCondTimedwaitand translates the SCE result to POSIX error numbers. The timeout unit/signature is inferred from shadPS4; console behavior remains unverified and is recorded in TechnicalDebt.Tested
libkernel,guest_pthread_spin_tests, andguest_cond_timedwait_testssuccessfully.guest_pthread_spinandguest_cond_timedwaitpassed 3 consecutive runs (6/6).python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Closes #3554.