feat(libkernel): implement pthread_rwlock_reltimedrdlock_np and pthread_rwlock_reltimedwrlock_np #9265
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9265"
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 HQasper on 2026-10-21T16:56:55Z.
What
pthread_rwlock_reltimedrdlock_np(dYv-+If2GPk) andpthread_rwlock_reltimedwrlock_np(RRnSj8h8VR4) were missing fromlibkernel.prx, so a title importing either stopped at load withFAIL: unresolved ELF import ... from libkernel.prx.pthread_rwlock_timed*lockcalls: a zero lock is initialized as bypthread_rwlock_rdlock, thenscePthreadRwlockTimedrdlock/scePthreadRwlockTimedwrlockrun with the microsecond count and the SCE error is turned into a POSIX error number, the same waypthread_cond_reltimedwait_npmaps ontoscePthreadCondTimedwait.libkernel_sys/Export.Discovery.cppare removed, sincecheck_conventionsallows an export in one library only (duplicate-export). An import of these two fromlibkernel_sysnow no longer resolves, as for the other libkernel pthread calls.(rwlock, u32 usec)comes only from shadPS4, which registers one function for each of these NIDs and for itsscePthreadRwlockTimed*twin (rwlock.cpp); FreeBSD 11.4 libthr has no such functions. This is recorded in the libkernel debt file.Tested
Linux (Ubuntu container, GCC, Release,
BUILD_TESTING=ON):guest_pthread_rwlockwith a new relative-timeout case: passed. It checks a zero lock initialized by both calls,EINVALafter destroy, a shared read beside another reader,ETIMEDOUTafter at least 15 ms for a 20 ms timeout and at once for 0 against a reader and a writer, and that a long timeout succeeds once the holder lets go. Breaking the write call (timeout forced to 0) makes it fail.guest_cond_timedwaitandguest_kernel_sys(unchanged): passed.nid_patcher, the patchedlibkernel.prxexportsdYv-+If2GPkandRRnSj8h8VR4(nm -D).python3 tools/check_conventions.py --base upstream/main: passed.Windows 10 (MinGW-w64 GCC 15.2.0 WinLibs
x86_64-ucrt-posix-sehr7, Release,BUILD_TESTING=ON), on 923eb034b, which has the same implementation; the later commit only drops two test lines and moves the debt entry:guest_pthread_rwlock,guest_cond_timedwaitandguest_kernel_sys: 3 of 3 passed.Not tested: any title. None of the titles checked here import the two NIDs.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Duplicate and overlap check
Checked on 2026-10-21 against upstream
maincecb540a6and the heads of all 918 open pull requests:mainadds or changespthread_rwlock_reltimedrdlock_nporpthread_rwlock_reltimedwrlock_np; onmainthey appear only as the libkernel_sys stubs this removes (44c531bf0).main, and merging it with each open pull request adds no conflict that the pull request does not already have withmain.scePthreadRwlockTimed*locktime out instead of returningEDEADLKwhen the caller holds the write lock. These two calls inherit that, and the new test makes no claim about that case; with #9165 merged in,guest_pthread_rwlockstill passes. #8373 (rwlock attributes) and #9160 touch the same files in other places; the debt entry was placed away from #9160's and #9165's insertions.pthread_timedjoin_np) and #9072 (fiber attach) are other functions from the same scan.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T16:57:46Z.
Progress report (
d34da5d→8f13fe7)📈 System libraries: 42.12% (+0.02%, +2 implemented, -2 removed functions)
✅ 2 implemented
pthread_rwlock_reltimedrdlock_np_nid_postfixpthread_rwlock_reltimedwrlock_np_nid_postfix🗑️ 2 removed
pthread_rwlock_reltimedrdlock_np_nid_postfixpthread_rwlock_reltimedwrlock_np_nid_postfixImported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T18:17:10Z.
Review: APPROVED
Checked against main
a6646f8464and shadPS4 rwlock.cpp @3a9f57265d:dYv-+If2GPkandRRnSj8h8VR4hash from the two names.(rwlock, u32 usec)function for these NIDs and, viaORBIS(...), forscePthreadRwlockTimedrdlock/Timedwrlock. Forwarding to main'sscePthreadRwlockTimed*lock(rwlock, KernelUseconds)is therefore consistent, and the error mapping (ETIMEDOUT, EINVAL for a destroyed lock, EDEADLK when the caller holds the write lock) is the same one main's absolutepthread_rwlock_timed*lockalready uses.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.