Repository navigation
feat(libkernel): add missing pthread attribute accessors - #8373
Conversation
Progress report (9446779 → bb403de)📈 System libraries: 45.68% (+0.07%, +15 implemented functions) ✅ 15 implemented
|
|
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.
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.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
b99eaee to
bb403de
Compare
|
@slider a note on order with #10173 (ours, which makes One thing it changes for |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 522e32e and FreeBSD 11.4 libthr (thr_mutexattr.c L108-133, thr_mutex.c L207-218):
pthread_mutexattr_setkind_np/getkind_npmatch FreeBSD: errno EINVAL with -1 for a null or uninitialized attribute, getkind by value. The throw for kinds outside 1-4 stands in formutex_check_attr's later EINVAL and is recorded in libkernel.md, which seems the right call.- None of the 15 functions exist on current main, and the branch still merges cleanly into 522e32e. The only file shared with #9156 is libkernel.md (#9156 only adds
pthread_attr_*thread-attribute forms), so the two don't overlap. ToSceinvertsToErrnofor every value the wrapped POSIX functions return (0 or 22), andscePthreadMutexattrSetprotocolkeeps the 13.60-measured 0-2 range and EINVAL results while now storing the protocol.- Looks good to me; the #10173 ordering note above covers the only interaction I found.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
|
Checked the new accessors against FreeBSD 11.4 libthr and the existing POSIX/SCE pairs: |
What
Adds 15 missing pthread attribute accessors to libkernel. Most are the
scePthread*counterparts of POSIX functions that already exist.pthread_mutexattr_setkind_npandpthread_mutexattr_getkind_np, following FreeBSD 11.4 libthr (thr_mutexattr.c): an invalid attribute sets errno toEINVALand returns -1, and the kind is the mutex type. A kind outside 1 to 4 throws, becausepthread_mutex_inithere does not reject it withEINVALas FreeBSD'smutex_check_attrdoes. AlsoscePthreadMutexattrGettype,Getprotocol,Setprioceiling,Getprioceiling,SetpsharedandGetpshared.scePthreadMutexattrSetprotocolnow stores the protocol throughpthread_mutexattr_setprotocol, soscePthreadMutexattrGetprotocolreports it. It keeps the 0 to 2 range and theEINVALresults measured on a PS5 (firmware 13.60).pthread_cond_signalto_npover the existingscePthreadCondSignalto;scePthreadCondattrSetpsharedandscePthreadCondattrGetpshared.pthread_rwlockattr_gettype_npandscePthreadRwlockattrGettype, which report whatscePthreadRwlockattrSettypestored;scePthreadRwlockattrSetpsharedandscePthreadRwlockattrGetpshared.0x8002xxxx(newPosixThread::ToSce, the inverse ofToErrno), matching how shadPS4 registers these NIDs (ORBIS(posix_...)insrc/core/libraries/kernel/threads/{mutex,condvar,rwlock}.cpp).docs/dev/debt/libkernel.md):scePthreadMutexattrSetprotocol's entry is cut to what is still open, and the remaining gaps are recorded: thesetkind_npthrow,signaltowaking every waiter, and the unapplied rwlock type.Left out on purpose:
pthread_condattr_getclockandscePthreadCondattrGetclock, which feat(libkernel): implement pthread_condattr_getclock #8010 implements.pthread_rwlockattr_settype_np: the lock never applies the type, so it would be a new silent stub.scePthreadMutexattrGetkind/Setkind/Getgen/Setgen: their console behaviour is undocumented.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release):
guest_pthread_mutexattr,guest_pthread_condattr,guest_pthread_rwlockandguest_cond_timedwait. Thesignaltocase has a waiter woken bypthread_cond_signalto_npfrom another thread.guest_pthread_mutex_errors,guest_kernel_errors(measuredscePthreadMutexattrSetprotocolresults) andguest_pthread_destroyed_objectspass.ToSceor the stored value makes the new tests fail.tools/check_conventions.py --base origin/mainpasses.Windows: every changed source and test file passes a syntax-only check with MinGW-w64 GCC 13 (not the supported 15.2); not built or run.
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)