scePthreadMutexTrylock and some more libcinternal functions

This commit is contained in:
georgemoralis 2024-05-13 20:09:32 +03:00
parent f1883870fd
commit 413b67f8ce
3 changed files with 41 additions and 0 deletions

View file

@ -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);

View file

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

View file

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