feat(libSceNpCommon): implement the online ID utilities and the mutex, condition and clock wrappers #9037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9037"
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 YossiYad on 2026-10-21T10:22:22Z.
What
21 libSceNpCommon calls threw. They now follow shadPS4's np_common.cpp:
sceNpCmpOnlineIdcompares the 16 handle characters (NP_UTIL_ERROR_NOT_MATCHon a mismatch);sceNpCmpNpIdInOrderorders by handle, thenopt, thenreserved, and writes -1, 0 or 1;sceNpGetPlatformTypereads the tag atopt[4..7](none, PS3, Vita, PS4, elseINVALID_PLATFORM_TYPE);sceNpIntIsValidOnlineIdaccepts 3 to 16 characters, the first alphanumeric and the rest alphanumeric,_or-. A null argument isNP_ERROR_INVALID_ARGUMENT.sceNpMutex*andsceNpLwMutex*call the libkernelscePthreadMutex*functions; flag bit 0 makes the mutex recursive, and a busy try-lock isNP_LW_MUTEX_ERROR_BUSY.sceNpCondInit,Destroy,SignalandTimedwait(0 microseconds waits without a timeout, a timeout isNP_LW_COND_ERROR_TIMEDOUT),sceNpJoinThread,sceNpGetSystemClockUsecfrom the monotonic clock, andsceNpGetSdkVersion, which formats the system software version asmajor.minor.sceNpCreateThreadand the callout calls are left out. AnyPS5'sscePthread*functions already return SCE errors, so only the two NP-specific codes are mapped; shadPS4 converts errno values first. None of this is measured on a PS5; the debt entry says so, and the 21 "unknown signature" lines are removed.#6977, now merged, added a
sceNpCmpNpIdstub toPendingExports.cpp. This PR does not implement it, so the stub stays.Tested
Linux (Fedora 44, GCC, Ninja,
-DBUILD_TESTING=ON), based onmain2abfb1beb4:guest_np_common_ids,guest_np_common_syncandguest_np_common_clock(core/libs/tests/GuestNpCommon.cpp): ID comparison and ordering (includingopttaking precedence overreserved), all four platform tags and an unknown one, valid and invalid online IDs (2 and 16 characters, unterminated, leading-,.), a plain mutex reportingBUSYon a held try-lock while a flag-1 mutex locks twice, a 2 ms timed wait returningTIMEDOUTwith the mutex held again, a join returning the thread's value, the clock falling between twosceKernelClockGettimereads, and the version1.00written within 8 bytes. They abort onmain. Each of these breaks at least one case: ignoring the recursive flag, skipping either NP error mapping, a wrong platform number, dropping theoptcomparison, a 2 character minimum, rejecting_, a wrong clock id or unit, an unpadded minor version, and dropping the join value.ctest: 1787 of 1795 pass. The 8 failures fail the same way onmainon this machine and do not link libSceNpCommon:application_heap_scripting,application_heap_lazy,agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit,agc_driver_tessellationand the threenet_dontwait_blocking_*cases.tools/progress.py --compare: libraries +0.24%, 21 functions implemented, none lost.tools/check_conventions.py --base upstream/mainpasses.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T10:23:12Z.
Progress report (
4a17c71→4aba717)📈 System libraries: 42.18% (+0.19%, +21 implemented functions)
✅ 21 implemented
sceNpCmpNpIdInOrdersceNpCmpOnlineIdsceNpCondDestroysceNpCondInitsceNpCondSignalsceNpCondTimedwaitsceNpGetPlatformTypesceNpGetSdkVersionsceNpGetSystemClockUsecsceNpIntIsValidOnlineIdsceNpJoinThreadsceNpLwMutexDestroysceNpLwMutexInitsceNpLwMutexLocksceNpLwMutexTryLocksceNpLwMutexUnlocksceNpMutexDestroysceNpMutexInitsceNpMutexLocksceNpMutexTryLocksceNpMutexUnlockImported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-21T17:00:25Z.
Windows run: Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (ucrt-posix-seh r7), Ninja, Release,
BUILD_TESTING=ON.e0df782d2cmerged ontomaincecb540a63without conflicts, andlibSceNpCommonandguest_np_common_testsbuild with no warnings.guest_np_common_ids,_syncand_clockpass, three runs each.core/libs/prx/libSceNpCommonback tomainthey abort withsceNpCmpOnlineId not implemented,sceNpMutexInit not implementedandsceNpGetSystemClockUsec not implemented.np_common.cpp. Compare/order/validate, the platform tags, bit 0 as recursive, the BUSY and TIMEDOUT mappings, the monotonic clock and the%u.%02uversion all match. The only difference is the error mapping, and the description already covers it (AnyPS5'sscePthread*already return SCE codes).The Windows failure I hit is in #9063, not here. Details are over there.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T19:43:22Z.
Thanks @pipe1os for the Windows run and for going through all 21 against
np_common.cpp. Good to have the error mapping difference confirmed as the only one.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:34:51Z.
Rebased onto
mainda54c652e(head4aba71700). #6977 had added asceNpCmpNpIdstub toPendingExports.cpp, which this PR doesn't implement, so I kept it. Otherwise the change is line for line the same as before, andguest_np_commonpasses 3 of 3.@oneandonlydean @adriadam10 ready from my side: CI is green, and pipe1os ran it on Windows and checked the 21 calls against shadPS4.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T06:13:58Z.
@YossiYad thanks, it's in my review queue now. I'll come back here with the result.