From bd25d788a2b2bdbee48e9b0a15a8d24bc7570954 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 28 May 2024 19:20:07 -0400 Subject: [PATCH] kernel/slab: Disable the block allocator entirely if disabled. block_alloc and friends are now declared as static, so we got GCC errors about unused functions when USE_SLAB_ALLOCATOR_FOR_MALLOC was 0. So, instead, just don't initialize the block allocator at all. This was the change that triggered the prior commits: if the block allocator is completely disabled, the first object allocated through an object_cache is inside VMAddressSpace initialization, which happens during the interim period mentioned in previous commits. Haiku now can be built and booted all the way to the desktop with the kernel guarded heap enabled (and without the guarded heap substituting for the object cache.) Change-Id: If2f08a741826799127ecfd263d6c82ed4263eaab Reviewed-on: https://review.haiku-os.org/c/haiku/+/7701 Tested-by: Commit checker robot Reviewed-by: waddlesplash Haiku-Format: Haiku-format Bot --- src/system/kernel/slab/allocator.cpp | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/slab/allocator.cpp b/src/system/kernel/slab/allocator.cpp index cdcbc62546..54d2fe4cd6 100644 --- a/src/system/kernel/slab/allocator.cpp +++ b/src/system/kernel/slab/allocator.cpp @@ -23,6 +23,9 @@ #include "MemoryManager.h" +#if USE_SLAB_ALLOCATOR_FOR_MALLOC + + //#define TEST_ALL_CACHES_DURING_BOOT static const size_t kBlockSizes[] = { @@ -202,9 +205,6 @@ block_allocator_init_rest() // #pragma mark - public API -#if USE_SLAB_ALLOCATOR_FOR_MALLOC - - void* memalign(size_t alignment, size_t size) { @@ -295,6 +295,29 @@ realloc(void* address, size_t newSize) } +#else + + +void* +block_alloc_early(size_t size) +{ + panic("block allocator not enabled!"); + return NULL; +} + + +void +block_allocator_init_boot() +{ +} + + +void +block_allocator_init_rest() +{ +} + + #endif // USE_SLAB_ALLOCATOR_FOR_MALLOC