cleanup libc (wip) and separated it to several files
This commit is contained in:
parent
28a5277e2b
commit
bb578ae377
|
@ -30,6 +30,10 @@ set(LIBC_SOURCES src/core/hle/libraries/Libc/Libc.cpp
|
|||
src/core/hle/libraries/Libc/va_ctx.h
|
||||
src/core/hle/libraries/Libc/libc_cxa.cpp
|
||||
src/core/hle/libraries/Libc/libc_cxa.h
|
||||
src/core/hle/libraries/libc/libc_stdio.cpp
|
||||
src/core/hle/libraries/libc/libc_stdio.h
|
||||
src/core/hle/libraries/libc/libc_math.cpp
|
||||
src/core/hle/libraries/libc/libc_math.h
|
||||
)
|
||||
set(USERSERVICE_SOURCES src/core/hle/libraries/libuserservice/user_service.cpp
|
||||
src/core/hle/libraries/libuserservice/user_service.h
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#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 "ErrorCodes.h"
|
||||
#include "Libs.h"
|
||||
|
||||
|
@ -66,8 +68,8 @@ void LibC_Register(SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::exit);
|
||||
LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::atexit);
|
||||
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::printf);
|
||||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::vsnprintf);
|
||||
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);
|
||||
|
@ -80,12 +82,12 @@ void LibC_Register(SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("+P6FRGH4LfA", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::memmove);
|
||||
LIB_FUNCTION("kiZSXIWd9vg", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::strcpy);
|
||||
LIB_FUNCTION("Ls4tzzhimqQ", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::strcat);
|
||||
LIB_FUNCTION("EH-x713A99c", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::atan2f);
|
||||
LIB_FUNCTION("QI-x0SL8jhw", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::acosf);
|
||||
LIB_FUNCTION("ZE6RNL+eLbk", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::tanf);
|
||||
LIB_FUNCTION("GZWjF-YIFFk", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::asinf);
|
||||
LIB_FUNCTION("9LCjpWyQ5Zc", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::pow);
|
||||
LIB_FUNCTION("cCXjU72Z0Ow", "libc", 1, "libc", 1, 1,Core::Libraries::LibC::_Sin);
|
||||
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);
|
||||
|
||||
|
|
|
@ -2,22 +2,14 @@
|
|||
|
||||
#include <debug.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
PS4_SYSV_ABI int printf(VA_ARGS) {
|
||||
VA_CTX(ctx);
|
||||
return printf_ctx(&ctx);
|
||||
}
|
||||
void PS4_SYSV_ABI exit(int code) { std::exit(code); }
|
||||
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); }
|
||||
|
||||
PS4_SYSV_ABI void exit(int code) { std::exit(code); }
|
||||
|
||||
PS4_SYSV_ABI int atexit(void (*func)()) {
|
||||
int PS4_SYSV_ABI atexit(void (*func)()) {
|
||||
int rt = std::atexit(func);
|
||||
if (rt != 0) {
|
||||
BREAKPOINT();
|
||||
|
@ -48,16 +40,5 @@ char* PS4_SYSV_ABI strcpy(char* dest, const char* src) { return std::strcpy(dest
|
|||
char* PS4_SYSV_ABI strcat(char* dest, const char* src) { return std::strcat(dest, src); }
|
||||
|
||||
// math
|
||||
float PS4_SYSV_ABI atan2f(float y, float x) { return std::atan2f(y, x); }
|
||||
|
||||
float PS4_SYSV_ABI acosf(float num) { return std::acosf(num); }
|
||||
|
||||
float PS4_SYSV_ABI tanf(float num) { return std::tanf(num); }
|
||||
|
||||
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
|
|
@ -1,16 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include "printf.h"
|
||||
#include <cstddef>
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
// HLE functions
|
||||
PS4_SYSV_ABI int printf(VA_ARGS);
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
||||
PS4_SYSV_ABI void exit(int code);
|
||||
PS4_SYSV_ABI int atexit(void (*func)());
|
||||
|
||||
void PS4_SYSV_ABI exit(int code);
|
||||
int PS4_SYSV_ABI 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);
|
||||
void* PS4_SYSV_ABI memset(void* s, int c, size_t n);
|
||||
|
@ -22,11 +20,5 @@ char* PS4_SYSV_ABI strncpy(char* dest, const char* src, size_t count);
|
|||
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);
|
||||
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
|
|
@ -0,0 +1,18 @@
|
|||
#include "libc_math.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace Core::Libraries::LibC::math {
|
||||
|
||||
float PS4_SYSV_ABI atan2f(float y, float x) { return std::atan2f(y, x); }
|
||||
|
||||
float PS4_SYSV_ABI acosf(float num) { return std::acosf(num); }
|
||||
|
||||
float PS4_SYSV_ABI tanf(float num) { return std::tanf(num); }
|
||||
|
||||
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
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace Core::Libraries::LibC::math {
|
||||
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
|
|
@ -0,0 +1,10 @@
|
|||
#include "libc_stdio.h"
|
||||
|
||||
namespace Core::Libraries::LibC::stdio {
|
||||
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
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
#include "printf.h"
|
||||
|
||||
namespace Core::Libraries::LibC::stdio {
|
||||
int PS4_SYSV_ABI printf(VA_ARGS);
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
||||
|
||||
}
|
Loading…
Reference in New Issue