Commit Graph
293 Commits
Author SHA1 Message Date
Dean 67bbe03f91 Merge pull request #10173 from EagleBearerYS/fix/libkernel-rwlockattr-settype-types
fix(libkernel): store only rwlock attribute types 1 and 2
2026-10-25 06:39:50 +13:00
Adrià 137a8fab89 Merge pull request #7853 from ionut27001/fix/libkernel-rtprio-thread-lookup
fix(libkernel): report a thread's class and priority from rtprio_thread as measured on a PS5
2026-10-24 19:01:43 +02:00
Yunus Shaikh 49b6188c63 Merge main into fix/libkernel-rwlockattr-settype-types 2026-10-24 08:42:36 -07:00
Adrià c9b75825f3 Merge pull request #8373 from slider/feat/libkernel-pthread-attr-accessors
feat(libkernel): add missing pthread attribute accessors
2026-10-24 17:29:28 +02:00
Adrià 00198bfcdf Merge pull request #7838 from MarcZX10/codex/linux-thread-stack-reuse-7700
fix(libkernel): retain and reuse Linux guest thread stacks
2026-10-24 13:30:05 +02:00
Dean aeeaefad98 Merge pull request #8885 from hypermoist/feat/libc-sce-v2-thread-sync
feat(libc): add the std::__sce_v2 mutex, condition and thread calls
2026-10-24 21:09:55 +13:00
Dean e058b3284a Merge pull request #9167 from slider/feat/libkernel-named-semaphores
feat(libkernel): implement named POSIX semaphores
2026-10-24 21:09:30 +13:00
hypermistandClaude Opus 5.5 e813b210bc Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync
Kept both sides of GuestLibcThreads.cpp: main's ThreadHelpers test and this PR's VersionedSync test, both called from main().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 07:59:37 +13:00
orezraeyandClaude Opus 5.5 2a05015c2a fix(libkernel): refuse long thread names and answer a detach after a join as measured on a PS5
scePthreadCreate returns ENAMETOOLONG for a name of 32 bytes or more without creating the thread, and scePthreadDetach returns ESRCH for a joined thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:21:46 -03:00
Yunus Shaikh dd5a4a3e5a fix(libkernel): store only rwlock attribute types 1 and 2
scePthreadRwlockattrSettype stored any type and threw on a null
attribute. Measured against firmware 13.42's libkernel by BunnyFl in
#9632, it is the same function as pthread_rwlockattr_settype_np with
the error converted to an SCE code: types 1 and 2 are stored and return
0, and any other type, 0 included, or a null attribute or object
returns SCE_KERNEL_ERROR_EINVAL and stores nothing.
2026-10-23 04:42:16 -07:00
Dean 87f3526562 Merge pull request #8617 from Lindamea1/fix/libkernel-mutex-unlock-static-eperm
fix(libkernel): fail scePthreadMutexUnlock on a statically initialized mutex with EPERM
2026-10-23 21:08:24 +13:00
Dean c31f139db4 Merge pull request #8890 from UnhealthyKraken/feat/libkernel-pthread-timedjoin
feat(libkernel): implement pthread_timedjoin_np
2026-10-23 20:05:52 +13:00
SebastianandClaude Opus 5.5 bb403de88f feat(libkernel): add missing pthread attribute accessors
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-23 06:27:49 +00:00
Dean ee8a7349b5 Merge pull request #9265 from HQasper/claude/project-thread-6o4na3
feat(libkernel): implement pthread_rwlock_reltimedrdlock_np and pthread_rwlock_reltimedwrlock_np
2026-10-23 16:05:37 +13:00
3fcafeb420 fix(libkernel): keep the thread stack lock alive through static destruction
#9272 keeps liveStacks and protectedStackPages alive through static
destruction so that a late mprotect from an atexit handler can still
look up guest thread stacks. The mutex guarding them is still a static
std::mutex. libstdc++'s std::mutex has a trivial destructor, so it keeps
working on Linux, but libc++ destroys the pthread mutex, and a later lock
throws "mutex lock failed: Invalid argument": on macOS the exit probe of
guest_memory_lifetime fails at its mapping protection stage. The lock is
now allocated and never destroyed, like the maps.

The same change is part of #7201 and #8658.

Co-Authored-By: marion909 <[email protected]>
Co-Authored-By: iamthehimansh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 20:19:51 -04:00
Dean 9d3becbe51 Merge pull request #9272 from milescoviello/fix/thread-stack-maps-outlive-exit
fix(libkernel): keep the thread stack maps alive through static destruction
2026-10-23 13:05:31 +13:00
Kraken bf787dc895 chore(libkernel): merge current main for timed join integration 2026-10-22 15:25:35 +01:00
hypermistandClaude Opus 5.5 f465759bcf fix(libkernel): drop the duplicate scePthreadYield declaration
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-22 21:57:55 +13:00
hypermist a2d22219b4 Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync 2026-10-22 21:57:46 +13:00
Dean d6eafa54d0 Merge pull request #9279 from YossiYad/feat/kernel-sys-thread-defaults
feat(libkernel_sys): implement pthread_set_defaultstacksize_np, scePthreadSetDefaultstacksize and scePthreadSetName
2026-10-22 19:16:30 +13:00
Kang, Harry Zixuan 726edc503b feat(windows): support MSYS2 GCC runtime builds 2026-10-21 20:29:55 -07:00
Kraken 40c7168f9c Merge remote-tracking branch 'origin/main' into feat/libkernel-pthread-timedjoin 2026-10-22 03:48:39 +01:00
Adrià fe93440dfd Merge pull request #8502 from xXPBSXx/fix/pthread-barrier-count-limit
fix(libkernel): reject a pthread barrier count above INT_MAX like libthr
2026-10-21 21:02:25 +02:00
Adrià ea241c01b3 Merge pull request #8504 from xXPBSXx/fix/pthread-cond-timedwait-negative-seconds
fix(libkernel): reject a negative cond timedwait deadline like libthr
2026-10-21 20:29:21 +02:00
Yossi Yadgar bc09ce3128 feat(libkernel): keep the default thread stack size in one settable place 2026-10-21 20:24:13 +03:00
milescovielloandClaude Opus 5.5 5360173da5 fix(libkernel): keep the thread stack maps alive through static destruction
liveStacks, protectedStackPages and guestStackMappings were plain
globals, so libkernel's static destructors freed them at exit while
detached threads could still unregister their stacks or look one up.
ThreadSanitizer reports the race in guest_pthread_join_detach: the main
thread's static destruction of liveStacks against a detached thread's
UnregisterStack under stackLock. The maps are now created once and
never destroyed, as Apr.cpp does for its globals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:05:38 +00:00
Claude 8f13fe70b9 feat(libkernel): implement pthread_rwlock_reltimedrdlock_np and pthread_rwlock_reltimedwrlock_np
Both were missing from libkernel.prx, so a title importing either
(dYv-+If2GPk, RRnSj8h8VR4) failed to load. They take a relative timeout
in microseconds and are scePthreadRwlockTimedrdlock and
scePthreadRwlockTimedwrlock with POSIX error numbers; a zero lock is
initialized as by pthread_rwlock_rdlock. The signature comes from
shadPS4, which registers one function for each NID and its
scePthreadRwlockTimed* twin; FreeBSD 11.4 has no such calls. The throwing
libkernel_sys copies are removed, as an export may live in one library
only. Recorded in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-21 15:27:52 +00:00
SebastianandClaude Opus 5.5 9497840de5 feat(libkernel): implement named POSIX semaphores
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-21 13:58:38 +00:00
hypermist 8e08acba70 Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync
# Conflicts:
#	core/libs/tests/GuestLibcThreads.cpp
2026-10-22 02:52:08 +13:00
Adrià 5faed506a5 Merge pull request #8428 from hypermoist/feat/libkernel-pthread-cleanup-push
feat(libkernel): implement pthread_cleanup_push and pthread_cleanup_pop
2026-10-21 15:32:45 +02:00
Adrià 1ae3f38d9e Merge pull request #8400 from slider/feat/libkernel-mutex-np
feat(libkernel): add mutex ownership, relative lock and spin/yield accessors
2026-10-21 15:32:34 +02:00
Dean 1d2f8cfe0e Merge pull request #8859 from hypermoist/feat/libc-c11-thread-forwards
feat(libc): forward the C11 thread and TSS calls to libkernel
2026-10-22 01:54:23 +13:00
SebastianandClaude Opus 5.5 74bd5d9fa5 feat(libkernel): add mutex ownership, relative lock and spin/yield accessors
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-21 08:00:19 +00:00
Dean ef1f41c4c9 Merge pull request #8061 from Dragost/fix/libkernel-pthread-yield-busy-spin
fix(libkernel): prevent 100% CPU busy-spinning on pthread yield on Windows
2026-10-21 20:57:20 +13:00
Dragost 2716dee730 fix(libkernel): prevent 100% CPU busy-spinning on pthread yield on Windows 2026-10-21 09:30:27 +02:00
Kraken c44f3b59f7 feat(libkernel): implement pthread_timedjoin_np 2026-10-21 05:50:29 +01:00
hypermistandClaude Opus 5.5 a24473311c feat(libc): add the std::__sce_v2 mutex, condition and thread calls
The versioned Dinkumware entries operate on libkernel's own mutex,
condition and thread handles: _Mtx_init(_with_name), _Mtx_destroy,
_Mtx_lock, _Mtx_trylock, _Mtx_unlock, _Cnd_init(_with_name),
_Cnd_destroy, _Cnd_wait, _Cnd_signal, _Cnd_broadcast, _Thrd_detach,
_Thrd_join, _Thrd_yield, _Thrd_id and _Throw_Cpp_error. libkernel
registers the pthread calls with libc next to the C11 forwards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 17:25:01 +13:00
hypermistandClaude Opus 5.5 8bddc39245 feat(libc): forward the C11 thread and TSS calls to libkernel
_Call_once, _Tss_create, _Tss_delete, _Tss_get, _Tss_set, _Thrd_equal,
_Thrd_current and _Thrd_exit call scePthreadOnce, scePthreadKeyCreate,
scePthreadKeyDelete, scePthreadGetspecific, scePthreadSetspecific,
scePthreadEqual, scePthreadSelf and scePthreadExit and return their
results unchanged, as the console's libSceLibcInternal does.
_Mtx_current_owns returns 1 there. libkernel registers the calls with
libc at load, next to the pthread_create registration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 16:31:00 +13:00
Dean a806c69bfe Merge pull request #8758 from p3n1cillin/codex/pthread-getprio-20261021
feat(libkernel): implement pthread_getprio
2026-10-21 14:27:54 +13:00
p3nicillin 5a79dda21d feat(libkernel): implement pthread_getprio 2026-10-21 00:08:30 +01:00
cadenasynysterandClaude Sonnet 5.5 a8b6d1c411 feat(libc): implement _Thrd_detach
Animal Well (PPSA22520) imports _Thrd_detach (L7f7zYwBvZA) from libc.prx and nothing exports it, so the Windows loader stops at startup. Register libkernel's pthread_detach with libc like pthread_create and pthread_join, and return _Thrd_error (4) when it fails.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-20 21:31:16 +02:00
Lindamea1andClaude Opus 5.5 c68ffcfd21 fix(libkernel): fail scePthreadMutexUnlock on a statically initialized mutex with EPERM
scePthreadMutexUnlock resolved the slot with resolveMutex(mutex, false),
which throws "Mutex is not initialized" while the slot still holds the
static initializer (0) or the adaptive static initializer (1), so
unlocking a statically initialized mutex that was never locked ended
the process. FreeBSD 11.4's mutex_unlock_common returns EPERM for both
without initializing the slot, and EINVAL for the destroyed marker.

Load the slot once: the destroyed marker still returns 0x80020016, and
the two initializers now return 0x80020001 and stay in the slot, so a
later lock still creates the mutex.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 19:31:14 +01:00
MarcZX10 95872a323f fix(libkernel): discard finished cached stack pages 2026-10-20 18:28:15 +00:00
MarcZX10 f0f691b2de fix(libkernel): bound retained guest thread stacks 2026-10-20 18:28:15 +00:00
MarcZX10 203c250f72 fix(libkernel): retain and reuse Linux guest thread stacks 2026-10-20 18:28:15 +00:00
Dean 352dbe751a Merge pull request #8583 from Ondra97/codex/fix-pthread-attr-policy
fix(libkernel): report current thread scheduling policy in attributes
2026-10-21 07:14:27 +13:00
Dean 0b1d678fe5 Merge pull request #8148 from hamb3r/feat/libc-dinkumware-threads
feat(libc): export Dinkumware thread primitives from libc.prx
2026-10-21 06:21:49 +13:00
Ondra97 07486d7cfa fix(libkernel): report current thread scheduling policy in attributes 2026-10-20 19:05:08 +02:00
xXPBSXxandClaude Sonnet 5.5 894e9993a2 fix(libkernel): reject a negative cond timedwait deadline like libthr
_pthread_cond_timedwait fails an abstime with a negative tv_sec with EINVAL
before it looks at the condition variable or the mutex. pthread_cond_timedwait
took it as a deadline in the past and answered ETIMEDOUT.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 15:56:07 +02:00
xXPBSXxandClaude Sonnet 5.5 669455d1f2 fix(libkernel): reject a pthread barrier count above INT_MAX like libthr
_pthread_barrier_init fails a count above INT_MAX with EINVAL.
pthread_barrier_init accepted any count above zero.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 15:56:03 +02:00