mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 10:04:39 +00:00
Merge ca7cce079e
into 95a386308a
This commit is contained in:
commit
458019fffe
@ -30,6 +30,51 @@ s32 PS4_SYSV_ABI internal_memcmp(const void* s1, const void* s2, size_t n) {
|
|||||||
return std::memcmp(s1, s2, n);
|
return std::memcmp(s1, s2, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_malloc(size_t size) {
|
||||||
|
return std::malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PS4_SYSV_ABI internal_free(void* ptr) {
|
||||||
|
std::free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_operator_new(size_t size) {
|
||||||
|
if (size == 0) {
|
||||||
|
// Size of 1 is used if 0 is provided.
|
||||||
|
size = 1;
|
||||||
|
}
|
||||||
|
void* ptr = std::malloc(size);
|
||||||
|
ASSERT_MSG(ptr, "Failed to allocate new object with size {}", size);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PS4_SYSV_ABI internal_operator_delete(void* ptr) {
|
||||||
|
if (ptr) {
|
||||||
|
std::free(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI internal_posix_memalign(void** ptr, size_t alignment, size_t size) {
|
||||||
|
#ifdef _WIN64
|
||||||
|
void* allocated = _aligned_malloc(size, alignment);
|
||||||
|
if (!allocated) {
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
*ptr = allocated;
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return posix_memalign(ptr, alignment, size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_calloc(size_t num, size_t size) {
|
||||||
|
return std::calloc(num, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_realloc(void* ptr, size_t new_size) {
|
||||||
|
return std::realloc(ptr, new_size);
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym) {
|
void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym) {
|
||||||
|
|
||||||
LIB_FUNCTION("NFLs+dRJGNg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
LIB_FUNCTION("NFLs+dRJGNg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
@ -40,6 +85,19 @@ void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym) {
|
|||||||
internal_memset);
|
internal_memset);
|
||||||
LIB_FUNCTION("DfivPArhucg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
LIB_FUNCTION("DfivPArhucg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
internal_memcmp);
|
internal_memcmp);
|
||||||
|
LIB_FUNCTION("gQX+4GDQjpM", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_malloc);
|
||||||
|
LIB_FUNCTION("tIhsqj0qsFE", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, internal_free);
|
||||||
|
LIB_FUNCTION("fJnpuVVBbKk", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_operator_new);
|
||||||
|
LIB_FUNCTION("hdm0YfMa7TQ", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_operator_new);
|
||||||
|
LIB_FUNCTION("MLWl90SFWNE", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_operator_delete);
|
||||||
|
LIB_FUNCTION("z+P+xCnWLBk", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_operator_delete);
|
||||||
|
LIB_FUNCTION("cVSk9y8URbc", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1,
|
||||||
|
internal_posix_memalign);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::LibcInternal
|
} // namespace Libraries::LibcInternal
|
||||||
|
@ -10,5 +10,28 @@ class SymbolsResolver;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Libraries::LibcInternal {
|
namespace Libraries::LibcInternal {
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_memset(void* s, int c, size_t n);
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_memcpy(void* dest, const void* src, size_t n);
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI internal_memcpy_s(void* dest, size_t destsz, const void* src, size_t count);
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI internal_memcmp(const void* s1, const void* s2, size_t n);
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_malloc(size_t size);
|
||||||
|
|
||||||
|
void PS4_SYSV_ABI internal_free(void* ptr);
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_operator_new(size_t size);
|
||||||
|
|
||||||
|
void PS4_SYSV_ABI internal_operator_delete(void* ptr);
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI internal_posix_memalign(void** ptr, size_t alignment, size_t size);
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_calloc(size_t num, size_t size);
|
||||||
|
|
||||||
|
void* PS4_SYSV_ABI internal_realloc(void* ptr, size_t new_size);
|
||||||
|
|
||||||
void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym);
|
void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym);
|
||||||
} // namespace Libraries::LibcInternal
|
} // namespace Libraries::LibcInternal
|
@ -15,6 +15,7 @@
|
|||||||
#include "core/devtools/widget/module_list.h"
|
#include "core/devtools/widget/module_list.h"
|
||||||
#include "core/libraries/kernel/memory.h"
|
#include "core/libraries/kernel/memory.h"
|
||||||
#include "core/libraries/kernel/threads.h"
|
#include "core/libraries/kernel/threads.h"
|
||||||
|
#include "core/libraries/libc_internal/libc_internal_memory.h"
|
||||||
#include "core/linker.h"
|
#include "core/linker.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/tls.h"
|
#include "core/tls.h"
|
||||||
@ -49,7 +50,17 @@ static PS4_SYSV_ABI void* RunMainEntry [[noreturn]] (EntryParams* params) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Linker::Linker() : memory{Memory::Instance()} {}
|
Linker::Linker()
|
||||||
|
: memory{Memory::Instance()},
|
||||||
|
heap_api{new HeapAPI{.heap_malloc = &Libraries::LibcInternal::internal_malloc,
|
||||||
|
.heap_free = &Libraries::LibcInternal::internal_free,
|
||||||
|
.heap_calloc = &Libraries::LibcInternal::internal_calloc,
|
||||||
|
.heap_realloc = &Libraries::LibcInternal::internal_realloc,
|
||||||
|
.heap_memalign = nullptr,
|
||||||
|
.heap_posix_memalign = Libraries::LibcInternal::internal_posix_memalign,
|
||||||
|
.heap_reallocalign = nullptr,
|
||||||
|
.heap_malloc_stats = nullptr,
|
||||||
|
.heap_malloc_usable_size = nullptr}} {}
|
||||||
|
|
||||||
Linker::~Linker() = default;
|
Linker::~Linker() = default;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user