partial printf , hello world demo (not from OpenOrbis) works
This commit is contained in:
parent
809413a880
commit
825d38ef31
|
@ -1,9 +1,11 @@
|
||||||
#include "LibC.h"
|
#include "LibC.h"
|
||||||
#include "Libs.h"
|
|
||||||
#include "../Loader/Elf.h"
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "../Loader/Elf.h"
|
||||||
|
#include "Libs.h"
|
||||||
|
|
||||||
namespace HLE::Libs::LibC {
|
namespace HLE::Libs::LibC {
|
||||||
|
|
||||||
static u32 g_need_sceLibc = 1;
|
static u32 g_need_sceLibc = 1;
|
||||||
|
@ -16,8 +18,7 @@ namespace HLE::Libs::LibC {
|
||||||
static pthread_mutex_t __guard_mutex;
|
static pthread_mutex_t __guard_mutex;
|
||||||
static pthread_once_t __once_control = PTHREAD_ONCE_INIT;
|
static pthread_once_t __once_control = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
static void recursiveMutex()
|
static void recursiveMutex() {
|
||||||
{
|
|
||||||
pthread_mutexattr_t recursiveMutexAttr;
|
pthread_mutexattr_t recursiveMutexAttr;
|
||||||
pthread_mutexattr_init(&recursiveMutexAttr);
|
pthread_mutexattr_init(&recursiveMutexAttr);
|
||||||
pthread_mutexattr_settype(&recursiveMutexAttr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&recursiveMutexAttr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
@ -58,8 +59,7 @@ namespace HLE::Libs::LibC {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object)
|
void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object) {
|
||||||
{
|
|
||||||
*((uint8_t*)guard_object) = 1; // mark it as done
|
*((uint8_t*)guard_object) = 1; // mark it as done
|
||||||
|
|
||||||
// release global mutex
|
// release global mutex
|
||||||
|
@ -69,37 +69,29 @@ namespace HLE::Libs::LibC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) {
|
int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return ::memcmp(s1, s2, n); }
|
||||||
return ::memcmp(s1, s2, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) {
|
void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { return ::memcpy(dest, src, n); }
|
||||||
return ::memcpy(dest, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PS4_SYSV_ABI void catchReturnFromMain(int status) { BREAKPOINT();
|
static PS4_SYSV_ABI void catchReturnFromMain(int status) {
|
||||||
|
// dummy
|
||||||
}
|
}
|
||||||
static PS4_SYSV_ABI void exit(int code) { BREAKPOINT();
|
static PS4_SYSV_ABI void exit(int code) { ::exit(code); }
|
||||||
}
|
static PS4_SYSV_ABI int atexit(void (*func)()) {
|
||||||
static PS4_SYSV_ABI int atexit(void (*func)())
|
|
||||||
{
|
|
||||||
int rt = ::atexit(func);
|
int rt = ::atexit(func);
|
||||||
if (rt != 0)
|
if (rt != 0) {
|
||||||
{
|
|
||||||
BREAKPOINT();
|
BREAKPOINT();
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
static PS4_SYSV_ABI void _Assert() { BREAKPOINT(); }
|
static PS4_SYSV_ABI void _Assert() { BREAKPOINT(); }
|
||||||
|
|
||||||
static PS4_SYSV_ABI int printf() { /*
|
static PS4_SYSV_ABI int printf(const char* s) {
|
||||||
BREAKPOINT();*/
|
puts(s);
|
||||||
//PRINT_DUMMY_FUNCTION_NAME();
|
|
||||||
return 0; // not correct
|
return 0; // not correct
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibC_Register(SymbolsResolver* sym)
|
void LibC_Register(SymbolsResolver* sym) {
|
||||||
{
|
|
||||||
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
||||||
LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1, __cxa_guard_acquire);
|
LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1, __cxa_guard_acquire);
|
||||||
LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1, __cxa_guard_release);
|
LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1, __cxa_guard_release);
|
||||||
|
@ -114,4 +106,4 @@ namespace HLE::Libs::LibC {
|
||||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &HLE::Libs::LibC::g_need_sceLibc);
|
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &HLE::Libs::LibC::g_need_sceLibc);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}; // namespace HLE::Libs::LibC
|
Loading…
Reference in New Issue