-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
133 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// SPDX-License-Identifier: MIT | ||
// #include <FEXCore/Utils/CompilerDefs.h> | ||
|
||
#ifdef ENABLE_JEMALLOC | ||
#include <jemalloc/jemalloc.h> | ||
#endif | ||
|
||
#include <malloc.h> | ||
#include <stdlib.h> | ||
|
||
namespace FEXCore::Allocator { | ||
|
||
using mmap_hook_type = void* (*)(void* addr, size_t length, int prot, int flags, int fd, off_t offset); | ||
using munmap_hook_type = int (*)(void* addr, size_t length); | ||
|
||
#ifdef ENABLE_JEMALLOC | ||
void* malloc(size_t size) { | ||
return ::je_malloc(size); | ||
} | ||
void* calloc(size_t n, size_t size) { | ||
return ::je_calloc(n, size); | ||
} | ||
void* memalign(size_t align, size_t s) { | ||
return ::je_memalign(align, s); | ||
} | ||
void* valloc(size_t size) { | ||
return ::je_valloc(size); | ||
} | ||
int posix_memalign(void** r, size_t a, size_t s) { | ||
return ::je_posix_memalign(r, a, s); | ||
} | ||
void* realloc(void* ptr, size_t size) { | ||
return ::je_realloc(ptr, size); | ||
} | ||
void free(void* ptr) { | ||
return ::je_free(ptr); | ||
} | ||
size_t malloc_usable_size(void* ptr) { | ||
return ::je_malloc_usable_size(ptr); | ||
} | ||
void* aligned_alloc(size_t a, size_t s) { | ||
return ::je_aligned_alloc(a, s); | ||
} | ||
void aligned_free(void* ptr) { | ||
return ::je_free(ptr); | ||
} | ||
|
||
extern "C" mmap_hook_type je___mmap_hook; | ||
extern "C" munmap_hook_type je___munmap_hook; | ||
|
||
void SetJemallocMmapHook(mmap_hook_type Hook) { | ||
je___mmap_hook = Hook; | ||
} | ||
void SetJemallocMunmapHook(munmap_hook_type Hook) { | ||
je___munmap_hook = Hook; | ||
} | ||
|
||
#elif defined(_WIN32) | ||
#error "Tried building _WIN32 without jemalloc" | ||
|
||
#else | ||
void* malloc(size_t size) { | ||
return ::malloc(size); | ||
} | ||
void* calloc(size_t n, size_t size) { | ||
return ::calloc(n, size); | ||
} | ||
void* memalign(size_t align, size_t s) { | ||
return ::memalign(align, s); | ||
} | ||
void* valloc(size_t size) { | ||
return ::valloc(size); | ||
} | ||
int posix_memalign(void** r, size_t a, size_t s) { | ||
return ::posix_memalign(r, a, s); | ||
} | ||
void* realloc(void* ptr, size_t size) { | ||
return ::realloc(ptr, size); | ||
} | ||
void free(void* ptr) { | ||
return ::free(ptr); | ||
} | ||
size_t malloc_usable_size(void* ptr) { | ||
return ::malloc_usable_size(ptr); | ||
} | ||
void* aligned_alloc(size_t a, size_t s) { | ||
return ::aligned_alloc(a, s); | ||
} | ||
void aligned_free(void* ptr) { | ||
return ::free(ptr); | ||
} | ||
|
||
void SetJemallocMmapHook(mmap_hook_type) {} | ||
void SetJemallocMunmapHook(munmap_hook_type) {} | ||
|
||
#endif | ||
} // namespace FEXCore::Allocator |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters