Commit Graph
321 Commits
Author SHA1 Message Date
Adrià e796ed4e5e Merge pull request #9632 from EagleBearerYS/feat/libkernel-sys-libthr-names
feat(libkernel): add pthread_rwlockattr_settype_np and scePthreadMutexattrSetkind
2026-10-26 11:20:50 +01:00
Dean 4c752cafc9 Merge pull request #10177 from orezraey/fix/libkernel-cond-destroyed-measured-ps5
fix(libkernel): mark a destroyed condition variable with 1 and accept destroying a null one, as measured on a PS5
2026-10-26 21:29:48 +13:00
Dean de2e6728f3 Merge pull request #8616 from Lindamea1/fix/libkernel-posix-sem-post-notify-under-lock
fix(libkernel): notify a POSIX semaphore waiter before sem_post releases its lock
2026-10-26 11:02:29 +13:00
Yunus Shaikh 3a47ea6ea4 Merge main into feat/libkernel-sys-libthr-names
Main's #9573 implements scePthreadResume right after the
scePthreadMutexattrSetkind stub this branch removes from libkernel_sys;
the merge takes main's scePthreadResume and leaves the stub out.

Main's public-header audit wants one header declaration per export, so
the merge declares this branch's scePthreadMutexattrSetkind,
scePthreadMutexattrGetkind and pthread_rwlockattr_settype_np in
libkernel's Api.hpp, drops their stub declarations from libkernel_sys's
Api.hpp, has Mutex.cpp take sceKernelError from libkernel's Api.hpp,
and has the test include the libkernel headers instead of its own
declarations.
2026-10-25 12:49:51 -07:00
Adrià aeff26bd97 Merge pull request #9573 from zaryabzip/feat/pthread-create-suspended
feat(libkernel_sys): create threads suspended and resume them
2026-10-25 20:21:07 +01:00
Adrià 7a25f87620 Merge pull request #9500 from GitamarT045T3R/fix/libkernel-condattr-setclock
fix(libkernel): reject clocks libthr does not accept in pthread_condattr_setclock
2026-10-25 18:42:46 +01:00
zaryabzip 0b60e97834 feat(libkernel_sys): create threads suspended and resume them
Implement pthread_attr_setcreatesuspend_np, pthread_resume_np,
pthread_resume_all_np and pthread_multi_np with the sce forms
scePthreadAttrSetcreatesuspend, scePthreadResume, scePthreadResumeAll
and scePthreadMulti, following FreeBSD 11.4 libthr and the firmware
13.42 libkernel_sys module. A thread created suspended waits before its
start routine, outside any cancellation point, until it is resumed.
sceKernelRaiseException throws on Windows for a thread still suspended
at creation.
2026-10-25 21:51:02 +05:00
valenciana-nc 37ba4a9d2f fix(libkernel): reject ended threads in pthread_attr_get_np 2026-10-25 15:49:57 +01:00
orezraeyandClaude Opus 5.5 284884d40b Merge main into fix/libkernel-cond-destroyed-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 22:12:05 -03:00
Dean c6b318cfd9 Merge pull request #9165 from MaxLikesCode/fix/pthread-timed-self-lock
fix(libkernel): time out timed locks of a lock the caller already holds
2026-10-25 14:01:45 +13:00
MaxandClaude Opus 5.5 55ff5484d6 fix(libkernel): time out timed locks of a lock the caller already holds
scePthreadMutexTimedlock on a mutex the caller holds, and
scePthreadRwlockTimedrdlock and scePthreadRwlockTimedwrlock on a rwlock
it holds for writing, returned EDEADLK at once. The console returns
ETIMEDOUT, as the prosper console oracle measured. They now sleep until
the timeout and return ETIMEDOUT, as FreeBSD libthr does. The POSIX
timed locks call these and change with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 02:15:31 +02:00
Dean cf528e78c6 Merge pull request #9160 from yabanana/feat/kernel-sys-thread-queries
feat(libkernel_sys): identify the initial pthread
2026-10-25 12:57:53 +13:00
Daniele Giovane 32926902b8 Merge main and leave pthread attributes to the earlier contribution 2026-10-24 22:38:29 +02:00
boykopovar fdf9ca7574 fix(sdk): reconcile public headers after rebase 2026-10-24 23:17:47 +03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
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
orezraeyandClaude Opus 5.5 a431d14efe fix(libkernel): mark a destroyed condition variable with 1 and accept destroying a null one, as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 08:52:48 -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
Yunus Shaikh ca39134f27 fix(libkernel): answer the measured rwlock type and mutex kind cases
BunnyFl measured these functions against firmware 13.42's libkernel and
libkernel_sys in the PR thread (behaviour only):

- pthread_rwlockattr_settype_np stores only types 1 and 2. Any other
  type, 0 included, and a null attribute or object return EINVAL and
  store nothing; type 0 was stored before.
- scePthreadMutexattrSetkind returns 0x8001FFFF, sceKernelError(-1), for
  a null attribute or object instead of throwing. Kinds 1 to 4 are set as
  before; other kinds still throw, since the firmware stores them
  unchecked and a mutex's behaviour with them is not measured.
- scePthreadMutexattrGetkind takes the attribute itself and returns
  sceKernelError of its kind, or 0x8001FFFF for a null one.
2026-10-23 04:39:14 -07:00
Daniele Giovane bc00fafac0 Merge main and address review for PR 9160 2026-10-23 12:45:54 +02:00
Dean Galvin cee93db419 Merge main into feat/kernel-sys-thread-queries 2026-10-23 21:45:17 +13: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
Yunus Shaikh 96c21c0d09 Merge main into feat/libkernel-sys-libthr-names
# Conflicts:
#	core/libs/CMakeLists.txt
2026-10-22 20:56:19 -07: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
Yunus Shaikh e8172f8078 fix(libkernel): leave unmeasured scePthreadMutexattrSetkind inputs unimplemented
A null or uninitialized attribute, and a kind outside 1 to 4, threw
std::invalid_argument. They now go through NotImplemented_nid_no_patch,
as pthread_rwlockattr_settype_np's unmeasured types do. FreeBSD 11
libthr stores an unknown kind unchecked and answers a null attribute
with -1 and errno EINVAL, so scePthreadMutexattrSettype's
SCE_KERNEL_ERROR_EINVAL would match neither answer.
2026-10-22 01:44:01 -07:00
Itamar Medyoni 89031ca7b9 fix(libkernel): reject clocks libthr does not accept in pthread_condattr_setclock
FreeBSD 11 libthr's pthread_condattr_setclock returns EINVAL for any clock
other than CLOCK_REALTIME, CLOCK_VIRTUAL, CLOCK_PROF and CLOCK_MONOTONIC.
scePthreadCondattrSetclock stored any clock id; it now answers
SCE_KERNEL_ERROR_EINVAL for the others, and pthread_condattr_setclock
EINVAL through it.
2026-10-22 11:04:09 +03:00
Yunus Shaikh b23cbb5bb8 Merge main into feat/libkernel-sys-libthr-names
# Conflicts:
#	core/libs/prx/libkernel_sys/Export.Discovery.cpp
2026-10-21 23:43:23 -07: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
Yunus Shaikh fa3cbbe32b fix(libkernel): leave rwlock attribute types other than 0 to 2 unimplemented
pthread_rwlockattr_settype_np stored any type and returned 0. The console's answer to a type outside 0 to 2 is unknown, and shadPS4 returns EINVAL once the stored type is above 2, so such a type now goes through NotImplemented_nid_no_patch. Types 0 to 2 are stored but not applied, so the debt entry moves to the silent stubs.
2026-10-21 22:59:51 -07:00
Kang, Harry Zixuan 726edc503b feat(windows): support MSYS2 GCC runtime builds 2026-10-21 20:29:55 -07:00
Yunus Shaikh db33bdb16a feat(libkernel): add scePthreadMutexattrSetkind
The SCE name moves from a libkernel_sys stub to libkernel. Kinds
MutexType::ErrorCheck (1) to MutexType::Adaptive (4) are the mutex
types FreeBSD 11 libthr's pthread_mutexattr_setkind_np stores, and are
set through scePthreadMutexattrSettype, which maps the same values onto
those types. Other kinds and a null or uninitialized attribute throw, as
their console answer is not known.

guest_kernel_sys_pthread_np_kind round-trips kinds 2, 3, 4 and 1
through pthread_mutexattr_gettype, checks that kind 1 makes a second
lock return EDEADLK and kind 2 lets it succeed, and checks the throws
for kinds 0, 5 and -1 (the type unchanged) and for a destroyed or null
attribute.
2026-10-22 03:02:46 +00:00
Yunus Shaikh 0d81fe5712 feat(libkernel): add pthread_rwlockattr_settype_np
The POSIX name moves from a libkernel_sys stub to libkernel and stores the
type through its SCE twin scePthreadRwlockattrSettype, converting the
result as the other POSIX rwlock calls do.

guest_kernel_sys_pthread_np_rwlockattr checks types 0, 1 and 2 through
both names, a rwlock built from the attribute, and the throws for a
destroyed or null attribute.
2026-10-22 03:02:46 +00: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