diff --git a/src/builtins/sortTemplate.h b/src/builtins/sortTemplate.h index 6cc914a9..4c2c46b8 100644 --- a/src/builtins/sortTemplate.h +++ b/src/builtins/sortTemplate.h @@ -63,10 +63,6 @@ SOFTWARE. #define MIN(x,y) (((x) < (y) ? (x) : (y))) #endif -#ifndef CLZ -#define CLZ __builtin_clzll -#endif - static inline int compute_minrun(const uint64_t size) { const int top_bit = 64 - CLZ(size); const int shift = MAX(top_bit, 6) - 6; diff --git a/src/h.h b/src/h.h index 728e65fc..58010e48 100644 --- a/src/h.h +++ b/src/h.h @@ -114,6 +114,7 @@ #define FORCE_INLINE __attribute__((always_inline)) static inline #define NORETURN __attribute__((noreturn)) #define AUTO __auto_type +#define CLZ(X) __builtin_clzll(X) #define LIKELY(X) __builtin_expect(X,1) #define RARE(X) __builtin_expect(X,0) #define fsizeof(T,F,E,N) (offsetof(T, F) + sizeof(E)*(N)) // type, flexible array member name, flexible array member type, item amount diff --git a/src/jit/nvm_x86_64.c b/src/jit/nvm_x86_64.c index 210172e5..dc0a835b 100644 --- a/src/jit/nvm_x86_64.c +++ b/src/jit/nvm_x86_64.c @@ -18,7 +18,7 @@ EmptyValue* mmX_buckets[64]; u64 mmX_ctrs[64]; #define BSZ(X) (1ull<<(X)) -#define BSZI(X) ((u8)(64-__builtin_clzl((X)-1ull))) +#define BSZI(X) ((u8)(64-CLZ((X)-1ull))) #define MMI(X) X #define BN(X) mmX_##X #include "../opt/mm_buddyTemplate.h" @@ -27,7 +27,7 @@ u64 mmX_ctrs[64]; #define PROT PROT_READ|PROT_WRITE|PROT_EXEC #define FLAGS MAP_NORESERVE|MAP_PRIVATE|MAP_ANON|MAP_32BIT #include "../opt/mm_buddyTemplate.c" -static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-__builtin_clzl(sz-1ull), type); } +static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-CLZ(sz-1ull), type); } #undef BN #undef BSZ diff --git a/src/opt/mm_2buddy.h b/src/opt/mm_2buddy.h index aa20bf1d..99230c8d 100644 --- a/src/opt/mm_2buddy.h +++ b/src/opt/mm_2buddy.h @@ -19,7 +19,7 @@ extern EmptyValue* mm_buckets[128]; #include "mm_buddyTemplate.h" -#define LOG2(X) ((u8)(64-__builtin_clzl((X)-1ull))) +#define LOG2(X) ((u8)(64-CLZ((X)-1ull))) static void* mm_alloc(usz sz, u8 type) { assert(sz>=16); u32 log = LOG2(sz); diff --git a/src/opt/mm_buddy.h b/src/opt/mm_buddy.h index 91f56136..026c5d2f 100644 --- a/src/opt/mm_buddy.h +++ b/src/opt/mm_buddy.h @@ -19,7 +19,7 @@ extern EmptyValue* mm_buckets[64]; #include "mm_buddyTemplate.h" -#define LOG2(X) ((u8)(64-__builtin_clzl((X)-1ull))) +#define LOG2(X) ((u8)(64-CLZ((X)-1ull))) static void* mm_alloc(usz sz, u8 type) { assert(sz>=16); onAlloc(sz, type);