mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-29 23:03:18 +00:00
libc separate stdlib functions to libc_stdlib
This commit is contained in:
parent
f5526977d3
commit
fd535bae6b
6 changed files with 45 additions and 33 deletions
|
@ -2,33 +2,8 @@
|
|||
|
||||
#include <debug.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
void PS4_SYSV_ABI exit(int code) { std::exit(code); }
|
||||
|
||||
int PS4_SYSV_ABI atexit(void (*func)()) {
|
||||
int rt = std::atexit(func);
|
||||
if (rt != 0) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void* PS4_SYSV_ABI malloc(size_t size) { return std::malloc(size); }
|
||||
|
||||
void PS4_SYSV_ABI free(void* ptr) { std::free(ptr); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// math
|
||||
|
||||
}; // namespace Core::Libraries::LibC
|
|
@ -7,11 +7,7 @@ namespace Core::Libraries::LibC {
|
|||
|
||||
// HLE functions
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
|
26
src/core/hle/libraries/libc/libc_stdlib.cpp
Normal file
26
src/core/hle/libraries/libc/libc_stdlib.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "libc_stdlib.h"
|
||||
|
||||
#include <Util/log.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Core::Libraries::LibC::stdlib {
|
||||
constexpr bool log_file_libc = true; // disable it to disable logging
|
||||
|
||||
void PS4_SYSV_ABI exit(int code) { std::exit(code); }
|
||||
|
||||
int PS4_SYSV_ABI atexit(void (*func)()) {
|
||||
int rt = std::atexit(func);
|
||||
if (rt != 0) {
|
||||
LOG_ERROR_IF(log_file_libc, "atexit returned {}\n", rt);
|
||||
BREAKPOINT();
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
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
|
12
src/core/hle/libraries/libc/libc_stdlib.h
Normal file
12
src/core/hle/libraries/libc/libc_stdlib.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace Core::Libraries::LibC::stdlib {
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue