summaryrefslogtreecommitdiffhomepage
path: root/include/stc/ccommon.h
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-05-18 11:49:31 +0200
committerTyge Lovset <[email protected]>2023-05-18 11:49:31 +0200
commit50a16934dde8e65bbcf628d6342c1649f7e09365 (patch)
treea14f3347622979858ff60b95630877029cb46ef6 /include/stc/ccommon.h
parentbe7d9913d4a284bdeb7f0431482b5731b5ef31df (diff)
downloadSTC-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.h10
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__)