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.
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.
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.
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.
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.
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.