mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-03 12:57:27 +00:00
Merge pull request #13686 from 00xDisaster/test/libSceNpCommon-system-clock
feat(libSceNpCommon): null-check sceNpGetSystemClockUsec
This commit is contained in:
3 files changed
+5
No files matched your search
@@ -157,6 +157,7 @@ int APS5_VABI sceNpJoinThread(Pthread thread, void** retval) {
|
||||
}
|
||||
|
||||
int APS5_VABI sceNpGetSystemClockUsec(std::int64_t* usec) {
|
||||
if (usec == nullptr) return NP_ERROR_INVALID_ARGUMENT;
|
||||
KernelTimespec now{};
|
||||
const int result = sceKernelClockGettime(CLOCK_MONOTONIC_ID, &now);
|
||||
if (result == 0) *usec = now.tv_sec * 1000000 + now.tv_nsec / 1000;
|
||||
|
||||
@@ -132,6 +132,9 @@ static int testClock() {
|
||||
|
||||
bool ok = expect(sceNpGetSystemClockUsec(&usec) == 0, "the clock was not read");
|
||||
sceKernelClockGettime(4, &after);
|
||||
ok &= expect(sceNpGetSystemClockUsec(nullptr) == INVALID_ARGUMENT, "a null destination was not rejected");
|
||||
std::int64_t later = -1;
|
||||
ok &= expect(sceNpGetSystemClockUsec(&later) == 0 && later >= usec && usec >= 0, "the clock went backwards");
|
||||
|
||||
ok &= expect(usec >= before.tv_sec * 1000000 + before.tv_nsec / 1000 && usec <= after.tv_sec * 1000000 + after.tv_nsec / 1000, "the clock is not the monotonic kernel clock in microseconds");
|
||||
char version[12];
|
||||
|
||||
@@ -35,6 +35,7 @@ Pending import declarations are matched to names in the local libSceNpCommon.spr
|
||||
|
||||
- [Online ID and NpId utilities](../../../core/libs/prx/libSceNpCommon/Export.cpp) (libSceNpCommon) - `sceNpCmpOnlineId`, `sceNpCmpNpIdInOrder`, `sceNpGetPlatformType` and `sceNpIntIsValidOnlineId` are not measured on a console; their signatures, checks and results follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/np/np_common.cpp), including the platform tags read from `opt[4..7]` and the 3 to 16 character online ID rule.
|
||||
- [Mutex, condition and thread wrappers](../../../core/libs/prx/libSceNpCommon/Export.cpp) (libSceNpCommon) - the `sceNpMutex*`, `sceNpLwMutex*`, `sceNpCond*` and `sceNpJoinThread` wrappers forward to the libkernel `scePthread*` calls as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/np/np_common.cpp) and are not measured on a console. Only `EBUSY` from try-lock and `ETIMEDOUT` from a timed wait are mapped to NP errors; every other kernel error is returned unchanged. The `flags` argument of `sceNpCondInit` is ignored.
|
||||
- [sceNpGetSystemClockUsec](../../../core/libs/prx/libSceNpCommon/Export.cpp) (libSceNpCommon) - a null destination returns the invalid-argument error `0x80550003` as a host-safety fallback; shadPS4 writes through the pointer without checking it, and the console behaviour is not measured.
|
||||
- [sceNpGetSdkVersion](../../../core/libs/prx/libSceNpCommon/Export.cpp) (libSceNpCommon) - writes the libkernel system software version as `major.minor` into an 8-byte buffer without checking it, as shadPS4 does; that version is the fixed `1.00`, not the SDK version a title was built with.
|
||||
- [The exports in Runtime.cpp](../../../core/libs/prx/libSceNpCommon/Runtime.cpp) and [Strings.cpp](../../../core/libs/prx/libSceNpCommon/Strings.cpp) follow `libSceNpCommon.sprx` from firmware 13.60, read from disassembly and not measured on a console.
|
||||
- [The sce::np::Object new and delete operators](../../../core/libs/prx/libSceNpCommon/Runtime.cpp) (libSceNpCommon) - do not check that the size plus their 16-byte header fits, and free through the allocator stored in that header, ignoring the allocator passed to the delete forms, as `libSceNpCommon.sprx` of firmware 13.60 does, read from disassembly, not measured on a console. The extended forms keep the address of the `SceNpAllocatorEx` itself, whose first member is the allocator.
|
||||
|
||||
Reference in new issue
Block a user