diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index 5c2524b6..cfc3b8d1 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -964,6 +964,29 @@ int PS4_SYSV_ABI scePthreadCondattrDestroy(ScePthreadCondattr* attr) { } } +int PS4_SYSV_ABI scePthreadMutexTrylock(ScePthreadMutex* mutex) { + + if (mutex == nullptr) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + + int result = pthread_mutex_trylock(&(*mutex)->pth_mutex); + if (result != 0) { + LOG_INFO(Kernel_Pthread, "name={}, result={}", (*mutex)->name, result); + } + switch (result) { + case 0: + return ORBIS_OK; + case EAGAIN: + return ORBIS_KERNEL_ERROR_EAGAIN; + case EBUSY: + return ORBIS_KERNEL_ERROR_EBUSY; + case EINVAL: + default: + return ORBIS_KERNEL_ERROR_EINVAL; + } +} + void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetschedpolicy); LIB_FUNCTION("-Wreprtu0Qs", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetdetachstate); @@ -993,6 +1016,7 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("1FGvU0i9saQ", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexattrSetprotocol); LIB_FUNCTION("9UK1vLZQft4", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexLock); LIB_FUNCTION("tn3VlD0hG60", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexUnlock); + LIB_FUNCTION("upoVrzMHFeE", "libkernel", 1, "libkernel", 1, 1, scePthreadMutexTrylock); // cond calls LIB_FUNCTION("2Tb92quprl0", "libkernel", 1, "libkernel", 1, 1, scePthreadCondInit); LIB_FUNCTION("m5-2bsNfv7s", "libkernel", 1, "libkernel", 1, 1, scePthreadCondattrInit); diff --git a/src/core/libraries/libc_internal/libc_internal.cpp b/src/core/libraries/libc_internal/libc_internal.cpp index 2a9866b6..e140c225 100644 --- a/src/core/libraries/libc_internal/libc_internal.cpp +++ b/src/core/libraries/libc_internal/libc_internal.cpp @@ -13,6 +13,10 @@ void* PS4_SYSV_ABI internal_memset(void* s, int c, size_t n) { return std::memset(s, c, n); } +void* PS4_SYSV_ABI internal_memcpy(void* dest, const void* src, size_t n) { + return std::memcpy(dest, src, n); +} + errno_t PS4_SYSV_ABI internal_memcpy_s(void* dest, rsize_t destsz, const void* src, rsize_t count) { return memcpy_s(dest, destsz, src, count); } @@ -25,15 +29,22 @@ int PS4_SYSV_ABI internal_memcmp(const void* s1, const void* s2, size_t n) { return std::memcmp(s1, s2, n); } +float PS4_SYSV_ABI internal_expf(float x) { + return std::expf(x); +} + void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("NFLs+dRJGNg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_memcpy_s); + LIB_FUNCTION("Q3VBxCXhUHs", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, + internal_memcpy); LIB_FUNCTION("8zTFvBIAIN8", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_memset); LIB_FUNCTION("5Xa2ACNECdo", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_strcpy_s); LIB_FUNCTION("DfivPArhucg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_memcmp); + LIB_FUNCTION("8zsu04XNsZ4", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_expf); }; } // namespace Libraries::LibcInternal \ No newline at end of file diff --git a/src/core/libraries/libc_internal/libc_internal.h b/src/core/libraries/libc_internal/libc_internal.h index 37b16fd4..d24bc500 100644 --- a/src/core/libraries/libc_internal/libc_internal.h +++ b/src/core/libraries/libc_internal/libc_internal.h @@ -10,6 +10,12 @@ class SymbolsResolver; } namespace Libraries::LibcInternal { +void* PS4_SYSV_ABI internal_memset(void* s, int c, size_t n); +void* PS4_SYSV_ABI internal_memcpy(void* dest, const void* src, size_t n); +errno_t PS4_SYSV_ABI internal_memcpy_s(void* dest, rsize_t destsz, const void* src, rsize_t count); +errno_t PS4_SYSV_ABI internal_strcpy_s(char* dest, rsize_t dest_size, const char* src); +int PS4_SYSV_ABI internal_memcmp(const void* s1, const void* s2, size_t n); +float PS4_SYSV_ABI internal_expf(float x); void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::LibcInternal \ No newline at end of file