diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 10:34:00 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 10:34:00 -0700 |
commit | 19a41387633e53d64d8a0ae69f3d3d3e35641c8d (patch) | |
tree | a89dead6dd34f95b3e644edeb02fe1ca70a28784 /libmisc | |
parent | 4ba0b95dc825a83748b7cb2aa528411026d5bada (diff) | |
parent | 5dab625d981e0039a5d874f5d8a6f795472785bc (diff) |
Merge branch 'lukeshu/misc'
Diffstat (limited to 'libmisc')
-rw-r--r-- | libmisc/include/libmisc/macro.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h index d11b99f..fe61410 100644 --- a/libmisc/include/libmisc/macro.h +++ b/libmisc/include/libmisc/macro.h @@ -19,7 +19,7 @@ #define LM_ARRAY_LEN(ary) (sizeof(ary)/sizeof((ary)[0])) #define LM_CEILDIV(n, d) ( ((n)+(d)-1) / (d) ) #define LM_ROUND_UP(n, d) ( LM_CEILDIV(n, d) * (d) ) /** Return `n` rounded up to the nearest multiple of `d` */ -#define LM_NEXT_POWER_OF_2(x) ((1ULL)<<((sizeof(unsigned long long)*8)-__builtin_clzll(x))) +#define LM_NEXT_POWER_OF_2(x) ( (x) ? 1ULL<<((sizeof(unsigned long long)*8)-__builtin_clzll(x)) : 1) /* strings */ |