use consistent wrappers around clz/ffs

This commit is contained in:
Daniel Micay 2022-01-16 15:39:59 -05:00
parent 86f9c739ee
commit d8cb2d9f7a
2 changed files with 17 additions and 13 deletions

20
util.h
View file

@ -29,8 +29,18 @@
#define STRINGIFY(s) #s
#define ALIAS(f) __attribute__((alias(STRINGIFY(f))))
static inline int ffzl(unsigned long x) {
return __builtin_ffsl(~x);
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef unsigned __int128 u128;
static inline int clz64(u64 x) {
return __builtin_clzll(x);
}
static inline int ffz64(u64 x) {
return __builtin_ffsll(~x);
}
static inline size_t align(size_t size, size_t align) {
@ -40,12 +50,6 @@ static inline size_t align(size_t size, size_t align) {
COLD noreturn void fatal_error(const char *s);
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef unsigned __int128 u128;
#define U64_WIDTH 64
#if CONFIG_SEAL_METADATA