diff --git a/src/Core/PS4/HLE/LibC.cpp b/src/Core/PS4/HLE/LibC.cpp index 4ff9bc27..71e97a90 100644 --- a/src/Core/PS4/HLE/LibC.cpp +++ b/src/Core/PS4/HLE/LibC.cpp @@ -71,32 +71,23 @@ void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object) { } } -int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return ::memcmp(s1, s2, n); } -void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { return ::memcpy(dest, src, n); } static PS4_SYSV_ABI void catchReturnFromMain(int status) { // dummy } -static PS4_SYSV_ABI void exit(int code) { ::exit(code); } -static PS4_SYSV_ABI int atexit(void (*func)()) { - int rt = ::atexit(func); - if (rt != 0) { - BREAKPOINT(); - } - return rt; -} + static PS4_SYSV_ABI void _Assert() { BREAKPOINT(); } void LibC_Register(SymbolsResolver* sym) { LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env); LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1, __cxa_guard_acquire); LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1, __cxa_guard_release); - LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1, memcmp); - LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1, memcpy); + LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::memcmp); + LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::memcpy); LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain); - LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1, exit); - LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1, atexit); + LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::exit); + LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::atexit); LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert); LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::printf); diff --git a/src/Core/PS4/HLE/LibC.h b/src/Core/PS4/HLE/LibC.h index ee82b993..ea3915e2 100644 --- a/src/Core/PS4/HLE/LibC.h +++ b/src/Core/PS4/HLE/LibC.h @@ -7,12 +7,9 @@ namespace HLE::Libs::LibC { //functions static PS4_SYSV_ABI void init_env(); - static PS4_SYSV_ABI void exit(int code); static PS4_SYSV_ABI void _Assert(); static PS4_SYSV_ABI void catchReturnFromMain(int status); int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object); void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object); - int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n); - void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n); - + }; \ No newline at end of file diff --git a/src/Emulator/HLE/Libraries/LibC/libc.cpp b/src/Emulator/HLE/Libraries/LibC/libc.cpp index ae9e8eee..7d99a1f2 100644 --- a/src/Emulator/HLE/Libraries/LibC/libc.cpp +++ b/src/Emulator/HLE/Libraries/LibC/libc.cpp @@ -1,9 +1,29 @@ #include "libc.h" +#include + +#include +#include + namespace Emulator::HLE::Libraries::LibC { PS4_SYSV_ABI int printf(VA_ARGS) { VA_CTX(ctx); return printf_ctx(&ctx); } + +PS4_SYSV_ABI void exit(int code) { std::exit(code); } + +PS4_SYSV_ABI int atexit(void (*func)()) { + int rt = std::atexit(func); + if (rt != 0) { + BREAKPOINT(); + } + return rt; +} + +int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return std::memcmp(s1, s2, n); } + +void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { return std::memcpy(dest, src, n); } + }; // namespace Emulator::HLE::Libraries::LibC \ No newline at end of file diff --git a/src/Emulator/HLE/Libraries/LibC/libc.h b/src/Emulator/HLE/Libraries/LibC/libc.h index 4da2bb6e..c9f632fd 100644 --- a/src/Emulator/HLE/Libraries/LibC/libc.h +++ b/src/Emulator/HLE/Libraries/LibC/libc.h @@ -1,10 +1,15 @@ #pragma once #include + #include "printf.h" namespace Emulator::HLE::Libraries::LibC { - //HLE functions - PS4_SYSV_ABI int printf(VA_ARGS); -} \ No newline at end of file +// HLE functions +PS4_SYSV_ABI int printf(VA_ARGS); +PS4_SYSV_ABI void exit(int code); +PS4_SYSV_ABI int atexit(void (*func)()); +int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n); +void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n); +} // namespace Emulator::HLE::Libraries::LibC \ No newline at end of file