From 10e27e21420aaf034b033a3e99593420806656f9 Mon Sep 17 00:00:00 2001 From: Thor Preimesberger Date: Tue, 23 Sep 2025 18:20:54 -0400 Subject: [PATCH] Integrate into build system on other architectures, flags for gcc and clang respectively --- h_malloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/h_malloc.c b/h_malloc.c index ad002a4..b83007f 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -20,9 +20,12 @@ #include "random.h" #include "util.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wundef" #if __x86_64__ #include "immintrin.h" #endif +#pragma GCC diagnostic pop #ifdef USE_PKEY #include @@ -409,7 +412,11 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, const struct // randomize start location for linear search (uniform random choice is too slow) size_t random_index = get_random_u16_uniform(rng, slots); size_t first_bitmap = random_index / U64_WIDTH; -#if __x86_64__ && (__BMI2__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wundef" +// __BMI2__ is idiomatic to gcc unfortunately. +#if __x86_64__ && (__BMI2__ || (__clang__ && __BMI2INTRIN_H_)) +#pragma GCC diagnostic pop u64 random_split = ~(~0UL << _pext_u64(random_index, 8)); #else u64 random_split = ~(~0UL << (random_index - first_bitmap * U64_WIDTH));