diff options
| author | Tyge Lovset <[email protected]> | 2023-05-18 11:49:31 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2023-05-18 11:49:31 +0200 |
| commit | 50a16934dde8e65bbcf628d6342c1649f7e09365 (patch) | |
| tree | a14f3347622979858ff60b95630877029cb46ef6 /include/stc/ccommon.h | |
| parent | be7d9913d4a284bdeb7f0431482b5731b5ef31df (diff) | |
| download | STC-modified-50a16934dde8e65bbcf628d6342c1649f7e09365.tar.gz STC-modified-50a16934dde8e65bbcf628d6342c1649f7e09365.zip | |
Huge update: cqueue and cdeq completely rewritten. cvec and cdeq API harmonized. Docs update/improved.
Diffstat (limited to 'include/stc/ccommon.h')
| -rw-r--r-- | include/stc/ccommon.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index fd673696..07c72e2f 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -171,6 +171,16 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle, return NULL; } +STC_INLINE intptr_t cnextpow2(intptr_t n) { + n--; + n |= n >> 1, n |= n >> 2; + n |= n >> 4, n |= n >> 8; + n |= n >> 16; + #if INTPTR_SIZE == INT64_SIZE + n |= n >> 32; + #endif + return n + 1; +} /* Control block macros */ #define c_foreach(...) c_MACRO_OVERLOAD(c_foreach, __VA_ARGS__) |
