finished libc refactoring
This commit is contained in:
parent
fd535bae6b
commit
6fba3a4380
|
@ -105,8 +105,8 @@ add_executable(shadps4
|
|||
src/core/PS4/HLE/Kernel/event_queues.h
|
||||
src/core/PS4/HLE/Kernel/cpu_management.cpp
|
||||
src/core/PS4/HLE/Kernel/cpu_management.h
|
||||
src/core/PS4/HLE/LibC.cpp
|
||||
src/core/PS4/HLE/LibC.h
|
||||
|
||||
|
||||
|
||||
"src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/core/PS4/Util/aerolib.h" "src/core/PS4/Loader/SymbolsResolver.h" "src/core/PS4/Loader/SymbolsResolver.cpp" "src/core/PS4/HLE/Libs.cpp" "src/core/PS4/HLE/Libs.h" "src/core/PS4/HLE/LibKernel.cpp" "src/core/PS4/HLE/LibKernel.h" "src/core/PS4/HLE/LibSceGnmDriver.cpp" "src/core/PS4/HLE/LibSceGnmDriver.h" "src/core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/core/PS4/HLE/Kernel/ThreadManagement.h" "src/core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/core/PS4/HLE/Kernel/memory_management.cpp" "src/core/PS4/HLE/Kernel/memory_management.h" "src/core/PS4/GPU/gpu_memory.cpp" "src/core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/core/PS4/GPU/video_out_buffer.cpp" "src/core/PS4/GPU/video_out_buffer.h" "src/core/PS4/HLE/Graphics/graphics_render.cpp" "src/core/PS4/HLE/Graphics/graphics_render.h" "src/core/PS4/GPU/tile_manager.cpp" "src/core/PS4/GPU/tile_manager.h" "src/version.h" "src/emuTimer.cpp" "src/emuTimer.h" "src/core/hle/libraries/libkernel/time_management.cpp" "src/core/hle/libraries/libkernel/time_management.h")
|
||||
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#include "LibC.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../Loader/Elf.h"
|
||||
#include "core/hle/libraries/libc/libc.h"
|
||||
#include "core/hle/libraries/libc/libc_cxa.h"
|
||||
#include "core/hle/libraries/libc/libc_math.h"
|
||||
#include "core/hle/libraries/libc/libc_stdio.h"
|
||||
#include "core/hle/libraries/libc/libc_string.h"
|
||||
#include "core/hle/libraries/libc/libc_stdlib.h"
|
||||
#include "ErrorCodes.h"
|
||||
#include "Libs.h"
|
||||
|
||||
namespace HLE::Libs::LibC {
|
||||
|
||||
static u32 g_need_sceLibc = 1;
|
||||
|
||||
static PS4_SYSV_ABI void init_env() // every game/demo should probably
|
||||
{
|
||||
// dummy no need atm
|
||||
}
|
||||
|
||||
static PS4_SYSV_ABI void catchReturnFromMain(int status) {
|
||||
// dummy
|
||||
}
|
||||
|
||||
static PS4_SYSV_ABI void _Assert() { BREAKPOINT(); }
|
||||
|
||||
PS4_SYSV_ABI int puts(const char* s) {
|
||||
std::puts(s);
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
PS4_SYSV_ABI int rand() { return std::rand(); }
|
||||
|
||||
PS4_SYSV_ABI void _ZdlPv(void* ptr) { std::free(ptr); }
|
||||
PS4_SYSV_ABI void _ZSt11_Xbad_allocv() { BREAKPOINT(); }
|
||||
PS4_SYSV_ABI void _ZSt14_Xlength_errorPKc() { BREAKPOINT(); }
|
||||
PS4_SYSV_ABI void* _Znwm(u64 count) {
|
||||
if (count == 0) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
void* ptr = std::malloc(count);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
float PS4_SYSV_ABI _Fsin(float arg) { return std::sinf(arg); }
|
||||
|
||||
typedef int(PS4_SYSV_ABI* pfunc_QsortCmp)(const void*, const void*);
|
||||
thread_local static pfunc_QsortCmp compair_ps4;
|
||||
|
||||
int qsort_compair(const void* arg1, const void* arg2) { return compair_ps4(arg1, arg2); }
|
||||
|
||||
void PS4_SYSV_ABI qsort(void* ptr, size_t count,size_t size, int(PS4_SYSV_ABI* comp)(const void*, const void*)) {
|
||||
compair_ps4 = comp;
|
||||
std::qsort(ptr, count, size, qsort_compair);
|
||||
}
|
||||
|
||||
void LibC_Register(SymbolsResolver* sym) {
|
||||
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
||||
LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::cxa::__cxa_guard_acquire);
|
||||
LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::cxa::__cxa_guard_release);
|
||||
LIB_FUNCTION("2emaaluWzUw", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::cxa::__cxa_guard_abort);
|
||||
LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::string::memcmp);
|
||||
LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::string::memcpy);
|
||||
LIB_FUNCTION("8zTFvBIAIN8", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::memset);
|
||||
LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain);
|
||||
LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::stdlib::exit);
|
||||
LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::stdlib::atexit);
|
||||
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::stdio::printf);
|
||||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::stdio::vsnprintf);
|
||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||
LIB_FUNCTION("cpCOXWMgha0", "libc", 1, "libc", 1, 1, rand);
|
||||
LIB_FUNCTION("ZtjspkJQ+vw", "libc", 1, "libc", 1, 1, _Fsin);
|
||||
LIB_FUNCTION("AEJdIVZTEmo", "libc", 1, "libc", 1, 1, qsort);
|
||||
LIB_FUNCTION("Ovb2dSJOAuE", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::strcmp);
|
||||
LIB_FUNCTION("gQX+4GDQjpM", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::stdlib::malloc);
|
||||
LIB_FUNCTION("tIhsqj0qsFE", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::stdlib::free);
|
||||
LIB_FUNCTION("j4ViWNHEgww", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::strlen);
|
||||
LIB_FUNCTION("6sJWiWSRuqk", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::strncpy);
|
||||
LIB_FUNCTION("+P6FRGH4LfA", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::memmove);
|
||||
LIB_FUNCTION("kiZSXIWd9vg", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::strcpy);
|
||||
LIB_FUNCTION("Ls4tzzhimqQ", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::string::strcat);
|
||||
LIB_FUNCTION("EH-x713A99c", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::math::atan2f);
|
||||
LIB_FUNCTION("QI-x0SL8jhw", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::math::acosf);
|
||||
LIB_FUNCTION("ZE6RNL+eLbk", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::math::tanf);
|
||||
LIB_FUNCTION("GZWjF-YIFFk", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::math::asinf);
|
||||
LIB_FUNCTION("9LCjpWyQ5Zc", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::math::pow);
|
||||
LIB_FUNCTION("cCXjU72Z0Ow", "libc", 1, "libc", 1, 1, Core::Libraries::LibC::math::_Sin);
|
||||
|
||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &HLE::Libs::LibC::g_need_sceLibc);
|
||||
|
||||
LIB_FUNCTION("z+P+xCnWLBk", "libc", 1, "libc", 1, 1, _ZdlPv);
|
||||
LIB_FUNCTION("eT2UsmTewbU", "libc", 1, "libc", 1, 1, _ZSt11_Xbad_allocv);
|
||||
LIB_FUNCTION("tQIo+GIPklo", "libc", 1, "libc", 1, 1, _ZSt14_Xlength_errorPKc);
|
||||
LIB_FUNCTION("fJnpuVVBbKk", "libc", 1, "libc", 1, 1, _Znwm);
|
||||
}
|
||||
|
||||
}; // namespace HLE::Libs::LibC
|
|
@ -1,13 +0,0 @@
|
|||
#pragma once
|
||||
#include "../Loader/SymbolsResolver.h"
|
||||
|
||||
namespace HLE::Libs::LibC {
|
||||
|
||||
void LibC_Register(SymbolsResolver* sym);
|
||||
|
||||
//functions
|
||||
static PS4_SYSV_ABI void init_env();
|
||||
static PS4_SYSV_ABI void _Assert();
|
||||
static PS4_SYSV_ABI void catchReturnFromMain(int status);
|
||||
|
||||
};
|
|
@ -1,22 +1,23 @@
|
|||
#include "Libs.h"
|
||||
|
||||
#include "LibC.h"
|
||||
#include "LibKernel.h"
|
||||
#include "LibSceGnmDriver.h"
|
||||
#include <core/PS4/HLE/Graphics/video_out.h>
|
||||
#include "core/hle/libraries/libuserservice/user_service.h"
|
||||
#include "core/hle/libraries/libpad/pad.h"
|
||||
#include <core/hle/libraries/libsystemservice/system_service.h>
|
||||
#include "core/hle/libraries/libc/libc.h"
|
||||
|
||||
namespace HLE::Libs {
|
||||
|
||||
void Init_HLE_Libs(SymbolsResolver *sym) {
|
||||
LibC::LibC_Register(sym);
|
||||
|
||||
LibKernel::LibKernel_Register(sym);
|
||||
Graphics::VideoOut::videoOutRegisterLib(sym);
|
||||
LibSceGnmDriver::LibSceGnmDriver_Register(sym);
|
||||
Core::Libraries::LibUserService::userServiceSymbolsRegister(sym);
|
||||
Core::Libraries::LibPad::padSymbolsRegister(sym);
|
||||
Core::Libraries::LibSystemService::systemServiceSymbolsRegister(sym);
|
||||
Core::Libraries::LibC::libcSymbolsRegister(sym);
|
||||
}
|
||||
} // namespace HLE::Libs
|
|
@ -1,9 +1,96 @@
|
|||
#include "libc.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Util/log.h"
|
||||
#include "core/PS4/HLE/Libs.h"
|
||||
#include "core/hle/libraries/libc/libc.h"
|
||||
#include "core/hle/libraries/libc/libc_cxa.h"
|
||||
#include "core/hle/libraries/libc/libc_math.h"
|
||||
#include "core/hle/libraries/libc/libc_stdio.h"
|
||||
#include "core/hle/libraries/libc/libc_stdlib.h"
|
||||
#include "core/hle/libraries/libc/libc_string.h"
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
constexpr bool log_file_libc = true; // disable it to disable logging
|
||||
static u32 g_need_sceLibc = 1;
|
||||
|
||||
static PS4_SYSV_ABI void init_env() { PRINT_DUMMY_FUNCTION_NAME(); }
|
||||
|
||||
static PS4_SYSV_ABI void catchReturnFromMain(int status) { LOG_INFO_IF(log_file_libc, "catchReturnFromMain returned ={}\n", status); }
|
||||
|
||||
static PS4_SYSV_ABI void _Assert() {
|
||||
PRINT_DUMMY_FUNCTION_NAME();
|
||||
BREAKPOINT();
|
||||
}
|
||||
|
||||
PS4_SYSV_ABI void _ZdlPv(void* ptr) { std::free(ptr); }
|
||||
PS4_SYSV_ABI void _ZSt11_Xbad_allocv() {
|
||||
PRINT_DUMMY_FUNCTION_NAME();
|
||||
BREAKPOINT();
|
||||
}
|
||||
PS4_SYSV_ABI void _ZSt14_Xlength_errorPKc() {
|
||||
PRINT_DUMMY_FUNCTION_NAME();
|
||||
BREAKPOINT();
|
||||
}
|
||||
PS4_SYSV_ABI void* _Znwm(u64 count) {
|
||||
if (count == 0) {
|
||||
LOG_ERROR_IF(log_file_libc, "_Znwm count ={}\n", count);
|
||||
BREAKPOINT();
|
||||
}
|
||||
void* ptr = std::malloc(count);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void libcSymbolsRegister(SymbolsResolver* sym) {
|
||||
// cxa functions
|
||||
LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1, __cxa_guard_acquire);
|
||||
LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1, __cxa_guard_release);
|
||||
LIB_FUNCTION("2emaaluWzUw", "libc", 1, "libc", 1, 1, __cxa_guard_abort);
|
||||
|
||||
// stdlib functions
|
||||
LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1, exit);
|
||||
LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1, atexit);
|
||||
LIB_FUNCTION("gQX+4GDQjpM", "libc", 1, "libc", 1, 1, malloc);
|
||||
LIB_FUNCTION("tIhsqj0qsFE", "libc", 1, "libc", 1, 1, free);
|
||||
LIB_FUNCTION("cpCOXWMgha0", "libc", 1, "libc", 1, 1, rand);
|
||||
LIB_FUNCTION("AEJdIVZTEmo", "libc", 1, "libc", 1, 1, qsort);
|
||||
|
||||
// math functions
|
||||
LIB_FUNCTION("EH-x713A99c", "libc", 1, "libc", 1, 1, atan2f);
|
||||
LIB_FUNCTION("QI-x0SL8jhw", "libc", 1, "libc", 1, 1, acosf);
|
||||
LIB_FUNCTION("ZE6RNL+eLbk", "libc", 1, "libc", 1, 1, tanf);
|
||||
LIB_FUNCTION("GZWjF-YIFFk", "libc", 1, "libc", 1, 1, asinf);
|
||||
LIB_FUNCTION("9LCjpWyQ5Zc", "libc", 1, "libc", 1, 1, pow);
|
||||
LIB_FUNCTION("cCXjU72Z0Ow", "libc", 1, "libc", 1, 1, _Sin);
|
||||
LIB_FUNCTION("ZtjspkJQ+vw", "libc", 1, "libc", 1, 1, _Fsin);
|
||||
|
||||
// string functions
|
||||
LIB_FUNCTION("Ovb2dSJOAuE", "libc", 1, "libc", 1, 1, strcmp);
|
||||
LIB_FUNCTION("j4ViWNHEgww", "libc", 1, "libc", 1, 1, strlen);
|
||||
LIB_FUNCTION("6sJWiWSRuqk", "libc", 1, "libc", 1, 1, strncpy);
|
||||
LIB_FUNCTION("+P6FRGH4LfA", "libc", 1, "libc", 1, 1, memmove);
|
||||
LIB_FUNCTION("kiZSXIWd9vg", "libc", 1, "libc", 1, 1, strcpy);
|
||||
LIB_FUNCTION("Ls4tzzhimqQ", "libc", 1, "libc", 1, 1, strcat);
|
||||
LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1, memcmp);
|
||||
LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1, memcpy);
|
||||
LIB_FUNCTION("8zTFvBIAIN8", "libc", 1, "libc", 1, 1, memset);
|
||||
|
||||
// stdio functions
|
||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, printf);
|
||||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, vsnprintf);
|
||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||
|
||||
// misc
|
||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc);
|
||||
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
||||
LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain);
|
||||
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||
LIB_FUNCTION("z+P+xCnWLBk", "libc", 1, "libc", 1, 1, _ZdlPv);
|
||||
LIB_FUNCTION("eT2UsmTewbU", "libc", 1, "libc", 1, 1, _ZSt11_Xbad_allocv);
|
||||
LIB_FUNCTION("tQIo+GIPklo", "libc", 1, "libc", 1, 1, _ZSt14_Xlength_errorPKc);
|
||||
LIB_FUNCTION("fJnpuVVBbKk", "libc", 1, "libc", 1, 1, _Znwm);
|
||||
}
|
||||
|
||||
}; // namespace Core::Libraries::LibC
|
|
@ -1,15 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
#include <cstddef>
|
||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
// HLE functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void libcSymbolsRegister(SymbolsResolver* sym);
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// adapted from https://opensource.apple.com/source/libcppabi/libcppabi-14/src/cxa_guard.cxx.auto.html
|
||||
|
||||
namespace Core::Libraries::LibC::cxa {
|
||||
namespace Core::Libraries::LibC {
|
||||
constexpr bool log_file_cxa = true; // disable it to disable logging
|
||||
|
||||
// This file implements the __cxa_guard_* functions as defined at:
|
||||
|
@ -145,4 +145,4 @@ void PS4_SYSV_ABI __cxa_guard_abort(u64* guard_object) {
|
|||
setNotInUse(guard_object);
|
||||
}
|
||||
|
||||
} // namespace Core::Libraries::LibC::Cxa
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -4,8 +4,8 @@
|
|||
#include <pthread.h>
|
||||
#include <types.h>
|
||||
|
||||
namespace Core::Libraries::LibC::cxa {
|
||||
namespace Core::Libraries::LibC {
|
||||
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object);
|
||||
void PS4_SYSV_ABI __cxa_guard_release(u64* guard_object);
|
||||
void PS4_SYSV_ABI __cxa_guard_abort(u64* guard_object);
|
||||
} // namespace Core::Libraries::LibC::Cxa
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
namespace Core::Libraries::LibC::math {
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
float PS4_SYSV_ABI atan2f(float y, float x) { return std::atan2f(y, x); }
|
||||
|
||||
|
@ -15,4 +15,7 @@ float PS4_SYSV_ABI asinf(float num) { return std::asinf(num); }
|
|||
double PS4_SYSV_ABI pow(double base, double exponent) { return std::pow(base, exponent); }
|
||||
|
||||
double PS4_SYSV_ABI _Sin(double x) { return std::sin(x); }
|
||||
} // namespace Core::Libraries::LibC::math
|
||||
|
||||
float PS4_SYSV_ABI _Fsin(float arg) { return std::sinf(arg); }
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include <types.h>
|
||||
|
||||
namespace Core::Libraries::LibC::math {
|
||||
namespace Core::Libraries::LibC {
|
||||
float PS4_SYSV_ABI atan2f(float y, float x);
|
||||
float PS4_SYSV_ABI acosf(float num);
|
||||
float PS4_SYSV_ABI tanf(float num);
|
||||
float PS4_SYSV_ABI asinf(float num);
|
||||
double PS4_SYSV_ABI pow(double base, double exponent);
|
||||
double PS4_SYSV_ABI _Sin(double x);
|
||||
} // namespace Core::Libraries::LibC::math
|
||||
float PS4_SYSV_ABI _Fsin(float arg);
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -1,10 +1,13 @@
|
|||
#include "libc_stdio.h"
|
||||
|
||||
namespace Core::Libraries::LibC::stdio {
|
||||
namespace Core::Libraries::LibC {
|
||||
int PS4_SYSV_ABI printf(VA_ARGS) {
|
||||
VA_CTX(ctx);
|
||||
return printf_ctx(&ctx);
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); }
|
||||
} // namespace Core::Libraries::LibC::stdio
|
||||
|
||||
int PS4_SYSV_ABI puts(const char* s) { return std::puts(s); }
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -1,10 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
namespace Core::Libraries::LibC::stdio {
|
||||
namespace Core::Libraries::LibC {
|
||||
int PS4_SYSV_ABI printf(VA_ARGS);
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
||||
|
||||
}
|
||||
int PS4_SYSV_ABI puts(const char* s);
|
||||
} // namespace Core::Libraries::LibC
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Core::Libraries::LibC::stdlib {
|
||||
namespace Core::Libraries::LibC {
|
||||
constexpr bool log_file_libc = true; // disable it to disable logging
|
||||
|
||||
void PS4_SYSV_ABI exit(int code) { std::exit(code); }
|
||||
|
@ -23,4 +23,15 @@ void* PS4_SYSV_ABI malloc(size_t size) { return std::malloc(size); }
|
|||
|
||||
void PS4_SYSV_ABI free(void* ptr) { std::free(ptr); }
|
||||
|
||||
} // namespace Core::Libraries::LibC::stdlib
|
||||
typedef int(PS4_SYSV_ABI* pfunc_QsortCmp)(const void*, const void*);
|
||||
thread_local static pfunc_QsortCmp compair_ps4;
|
||||
|
||||
int qsort_compair(const void* arg1, const void* arg2) { return compair_ps4(arg1, arg2); }
|
||||
|
||||
void PS4_SYSV_ABI qsort(void* ptr, size_t count, size_t size, int(PS4_SYSV_ABI* comp)(const void*, const void*)) {
|
||||
compair_ps4 = comp;
|
||||
std::qsort(ptr, count, size, qsort_compair);
|
||||
}
|
||||
int PS4_SYSV_ABI rand() { return std::rand(); }
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
namespace Core::Libraries::LibC::stdlib {
|
||||
namespace Core::Libraries::LibC {
|
||||
void PS4_SYSV_ABI exit(int code);
|
||||
int PS4_SYSV_ABI atexit(void (*func)());
|
||||
void* PS4_SYSV_ABI malloc(size_t size);
|
||||
void PS4_SYSV_ABI free(void* ptr);
|
||||
} // namespace Core::Libraries::LibC::stdlib
|
||||
void PS4_SYSV_ABI qsort(void* ptr, size_t count, size_t size, int(PS4_SYSV_ABI* comp)(const void*, const void*));
|
||||
int PS4_SYSV_ABI rand();
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
namespace Core::Libraries::LibC::string {
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return std::memcmp(s1, s2, n); }
|
||||
|
||||
|
@ -22,4 +22,4 @@ char* PS4_SYSV_ABI strcat(char* dest, const char* src) { return std::strcat(dest
|
|||
|
||||
size_t PS4_SYSV_ABI strlen(const char* str) { return std::strlen(str); }
|
||||
|
||||
} // namespace Core::Libraries::LibC::string
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace Core::Libraries::LibC::string {
|
||||
namespace Core::Libraries::LibC {
|
||||
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);
|
||||
void* PS4_SYSV_ABI memset(void* s, int c, size_t n);
|
||||
|
@ -13,4 +14,4 @@ void* PS4_SYSV_ABI memmove(void* dest, const void* src, std::size_t count);
|
|||
char* PS4_SYSV_ABI strcpy(char* destination, const char* source);
|
||||
char* PS4_SYSV_ABI strcat(char* dest, const char* src);
|
||||
size_t PS4_SYSV_ABI strlen(const char* str);
|
||||
} // namespace Core::Libraries::LibC::string
|
||||
} // namespace Core::Libraries::LibC
|
Loading…
Reference in New Issue