mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-09 20:00:20 +02:00
It is dangerous for FEX to rely on the system CRT as calls can have side effects that are also visible to the running application, and if patches are applied to any CRT exports used during compilation the call checker would trigger a reentry into the JIT to compile the patch and hence deadlock. Only functions that FEX actively uses are implemented, with the rest triggering an abort.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#define _SECIMP
|
|
#define _CRTIMP
|
|
#include <cstdint>
|
|
#include "../Priv.h"
|
|
|
|
extern "C" {
|
|
|
|
#define JEMALLOC_NOTHROW __attribute__((nothrow))
|
|
JEMALLOC_NOTHROW extern void* je_malloc(size_t size);
|
|
JEMALLOC_NOTHROW extern void* je_calloc(size_t n, size_t size);
|
|
JEMALLOC_NOTHROW extern void* je_memalign(size_t align, size_t s);
|
|
JEMALLOC_NOTHROW extern void* je_valloc(size_t size);
|
|
JEMALLOC_NOTHROW extern int je_posix_memalign(void** r, size_t a, size_t s);
|
|
JEMALLOC_NOTHROW extern void* je_realloc(void* ptr, size_t size);
|
|
JEMALLOC_NOTHROW extern void je_free(void* ptr);
|
|
JEMALLOC_NOTHROW extern size_t je_malloc_usable_size(void* ptr);
|
|
JEMALLOC_NOTHROW extern void* je_aligned_alloc(size_t a, size_t s);
|
|
#undef JEMALLOC_NOTHROW
|
|
}
|
|
|
|
void* calloc(size_t NumOfElements, size_t SizeOfElements) {
|
|
return je_calloc(NumOfElements, SizeOfElements);
|
|
}
|
|
|
|
void free(void* Memory) {
|
|
je_free(Memory);
|
|
}
|
|
|
|
void* malloc(size_t Size) {
|
|
return je_malloc(Size);
|
|
}
|
|
|
|
void* realloc(void* Memory, size_t NewSize) {
|
|
return je_realloc(Memory, NewSize);
|
|
}
|
|
|
|
DLLEXPORT_FUNC(void*, _aligned_malloc, (size_t Size, size_t Alignment)) {
|
|
return je_aligned_alloc(Alignment, Size);
|
|
}
|
|
|
|
DLLEXPORT_FUNC(void, _aligned_free, (void* Memory)) {
|
|
je_free(Memory);
|
|
}
|