From d13d810b662d1b8a84f495f581c57be78e480578 Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Tue, 26 Nov 2019 18:02:59 +0000 Subject: [PATCH] Explicitly compute the size of two pointers Don't use bits::is64() when setting MIN_ALLOC_BITS --- src/mem/allocconfig.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mem/allocconfig.h b/src/mem/allocconfig.h index fd0edc2..6238af3 100644 --- a/src/mem/allocconfig.h +++ b/src/mem/allocconfig.h @@ -110,8 +110,9 @@ namespace snmalloc #endif // Minimum allocation size is space for two pointers. - static constexpr size_t MIN_ALLOC_BITS = bits::is64() ? 4 : 3; - static constexpr size_t MIN_ALLOC_SIZE = 1 << MIN_ALLOC_BITS; + static_assert(bits::next_pow2_const(sizeof(void*)) == sizeof(void*)); + static constexpr size_t MIN_ALLOC_SIZE = 2 * sizeof(void*); + static constexpr size_t MIN_ALLOC_BITS = bits::ctz_const(MIN_ALLOC_SIZE); // Slabs are 64 KiB unless constrained to 16 KiB. static constexpr size_t SLAB_BITS = ADDRESS_SPACE_CONSTRAINED ? 14 : 16;