diff options
author | PiJoules <6019989+PiJoules@users.noreply.github.com> | 2024-06-20 16:43:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 16:43:47 -0700 |
commit | d8091522664248a4ba73d8d1e7fa6ac57bfcf67c (patch) | |
tree | 9612d47b50bed99e646dfb351dda99321abe2d4e /libc/src | |
parent | 0ee2af5f7c4c941c4588a67c87cb39e7dfad5ce8 (diff) | |
download | llvm-d8091522664248a4ba73d8d1e7fa6ac57bfcf67c.zip llvm-d8091522664248a4ba73d8d1e7fa6ac57bfcf67c.tar.gz llvm-d8091522664248a4ba73d8d1e7fa6ac57bfcf67c.tar.bz2 |
[libc] Control freelist malloc buffer size with a config (#96248)
Rather than propgating a compile define, add an explicit cmake flag for
controlling the size. The default for baremetal is 100KB and the default
for others is 1GB.
Diffstat (limited to 'libc/src')
-rw-r--r-- | libc/src/stdlib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libc/src/stdlib/freelist_malloc.cpp | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt index 3b1ca3a..51d53e0d 100644 --- a/libc/src/stdlib/CMakeLists.txt +++ b/libc/src/stdlib/CMakeLists.txt @@ -390,6 +390,8 @@ else() malloc.h DEPENDS libc.src.__support.freelist_heap + COMPILE_OPTIONS + -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE} ) else() add_entrypoint_external( diff --git a/libc/src/stdlib/freelist_malloc.cpp b/libc/src/stdlib/freelist_malloc.cpp index 0be7f34..4d3c42c 100644 --- a/libc/src/stdlib/freelist_malloc.cpp +++ b/libc/src/stdlib/freelist_malloc.cpp @@ -17,14 +17,11 @@ namespace LIBC_NAMESPACE { namespace { -// Users can define LIBC_FREELIST_MALLOC_SIZE for setting the default buffer -// size used by freelist malloc. #ifdef LIBC_FREELIST_MALLOC_SIZE +// This is set via the LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE configuration. constexpr size_t SIZE = LIBC_FREELIST_MALLOC_SIZE; #else -// TODO: We should probably have something akin to what scudo/sanitizer -// allocators do where each platform defines this. -constexpr size_t SIZE = 0x40000000ULL; // 1GB +#error "LIBC_FREELIST_MALLOC_SIZE was not defined for this build." #endif LIBC_CONSTINIT FreeListHeapBuffer<SIZE> freelist_heap_buffer; } // namespace |