mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-24 20:35:01 +00:00
some dummy HLE functions and implementations in libc
This commit is contained in:
parent
7dc1f0a47b
commit
5b0e627dc0
5 changed files with 66 additions and 18 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "Libs.h"
|
||||
#include "../Loader/Elf.h"
|
||||
#include "../../../Debug.h"
|
||||
#include <pthread.h>
|
||||
|
||||
namespace HLE::Libs::LibC {
|
||||
|
||||
|
@ -12,16 +13,60 @@ namespace HLE::Libs::LibC {
|
|||
//dummy no need atm
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object)
|
||||
{
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
}
|
||||
static pthread_mutex_t __guard_mutex;
|
||||
static pthread_once_t __once_control = PTHREAD_ONCE_INIT;
|
||||
|
||||
int PS4_SYSV_ABI __cxa_guard_release(u64* guard_object)
|
||||
static void recursiveMutex()
|
||||
{
|
||||
pthread_mutexattr_t recursiveMutexAttr;
|
||||
pthread_mutexattr_init(&recursiveMutexAttr);
|
||||
pthread_mutexattr_settype(&recursiveMutexAttr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&__guard_mutex, &recursiveMutexAttr);
|
||||
}
|
||||
|
||||
static pthread_mutex_t* mutex_quard() {
|
||||
pthread_once(&__once_control, &recursiveMutex);
|
||||
return &__guard_mutex;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object) {
|
||||
if ((*((uint8_t*)guard_object) != 0)) // low 8 bits checks if its already init
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int result = ::pthread_mutex_lock(mutex_quard());
|
||||
if (result != 0) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
|
||||
// Check if another thread has completed initializer run
|
||||
if ((*((uint8_t*)guard_object) != 0)) { // check again if other thread init it
|
||||
int result = ::pthread_mutex_unlock(mutex_quard());
|
||||
if (result != 0) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (((uint8_t*)guard_object)[1] != 0) { // the second lowest byte marks if it's being used by a thread
|
||||
BREAKPOINT();
|
||||
}
|
||||
|
||||
// mark this guard object as being in use
|
||||
((uint8_t*)guard_object)[1] = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object)
|
||||
{
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
*((uint8_t*)guard_object) = 1;//mark it as done
|
||||
|
||||
// release global mutex
|
||||
int result = ::pthread_mutex_unlock(mutex_quard());
|
||||
if (result != 0) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue