vsnprintf implementation
This commit is contained in:
parent
2d4d39c54b
commit
675193fec3
|
@ -107,6 +107,7 @@ void PS4_SYSV_ABI qsort(void* ptr, size_t count,size_t size, int(PS4_SYSV_ABI* c
|
||||||
std::qsort(ptr, count, size, qsort_compair);
|
std::qsort(ptr, count, size, qsort_compair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -119,6 +120,7 @@ void LibC_Register(SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::atexit);
|
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("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::printf);
|
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::printf);
|
||||||
|
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::vsnprintf);
|
||||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||||
LIB_FUNCTION("cpCOXWMgha0", "libc", 1, "libc", 1, 1, rand);
|
LIB_FUNCTION("cpCOXWMgha0", "libc", 1, "libc", 1, 1, rand);
|
||||||
LIB_FUNCTION("ZtjspkJQ+vw", "libc", 1, "libc", 1, 1, _Fsin);
|
LIB_FUNCTION("ZtjspkJQ+vw", "libc", 1, "libc", 1, 1, _Fsin);
|
||||||
|
|
|
@ -12,6 +12,8 @@ PS4_SYSV_ABI int printf(VA_ARGS) {
|
||||||
return printf_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); }
|
||||||
|
|
||||||
PS4_SYSV_ABI void exit(int code) { std::exit(code); }
|
PS4_SYSV_ABI void exit(int code) { std::exit(code); }
|
||||||
|
|
||||||
PS4_SYSV_ABI int atexit(void (*func)()) {
|
PS4_SYSV_ABI int atexit(void (*func)()) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Emulator::HLE::Libraries::LibC {
|
||||||
|
|
||||||
// HLE functions
|
// HLE functions
|
||||||
PS4_SYSV_ABI int printf(VA_ARGS);
|
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 void exit(int code);
|
||||||
PS4_SYSV_ABI int atexit(void (*func)());
|
PS4_SYSV_ABI int atexit(void (*func)());
|
||||||
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);
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
#include <cstdbool>
|
#include <cstdbool>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include "va_ctx.h"
|
#include "va_ctx.h"
|
||||||
|
|
||||||
namespace Emulator::HLE::Libraries::LibC {
|
namespace Emulator::HLE::Libraries::LibC {
|
||||||
|
@ -693,4 +693,10 @@ static int printf_ctx(VaCtx* ctx) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) {
|
||||||
|
char buffer[n];
|
||||||
|
int result = _vsnprintf(_out_buffer, buffer, format, arg);
|
||||||
|
std::strcpy(s, buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
} // namespace Emulator::HLE::Libraries::LibC
|
} // namespace Emulator::HLE::Libraries::LibC
|
||||||
|
|
Loading…
Reference in New Issue