diff options
| author | 2023-06-01 23:16:48 +0200 | |
|---|---|---|
| committer | 2023-06-01 23:27:20 +0200 | |
| commit | 65ace14e184807df026e985e073b3b5c5aaf576c (patch) | |
| tree | d4554e0eef30b6f8771bfa90835ff6dcb95198a7 /common.h | |
| parent | a98075934ece8c7ff351f8449f6515c12b9feec8 (diff) | |
basic ABI lowering of aggregates
Diffstat (limited to 'common.h')
| -rw-r--r-- | common.h | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -58,7 +58,7 @@ ptrhash(const void *p) { } static inline uint popcnt(uvlong x) { -#ifdef __GNUC__ +#if defined __has_builtin && __has_builtin(__builtin_popcountll) return __builtin_popcountll(x); #else uint n = 0; @@ -68,7 +68,17 @@ popcnt(uvlong x) { } static inline bool ispo2(uvlong x) { - return (x & (x - 1)) == 0; + return x & ((x & (x - 1)) == 0); +} +static inline uint +ilog2(uint x) { /* assumes x is a power of 2 */ +#if defined __has_builtin && __has_builtin(__builtin_ctz) + return __builtin_ctz(x); +#else + uint n = 0; + while (x >>= 1) ++n; + return n; +#endif } /******************/ |