aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-03-15 19:13:47 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-03-15 19:13:47 +0100
commitdd69874c5e0bfcef68e196ef02ae2f1be0a1b611 (patch)
treec78cf43562e1398bb66d260fd53b28b95c22b00d
parent5de5ec462319197ac19ea1a08f187e82f68cc10f (diff)
downloadprops.lv2-dd69874c5e0bfcef68e196ef02ae2f1be0a1b611.tar.xz
add macro for next power of 2.
-rw-r--r--VERSION2
-rw-r--r--props.h5
2 files changed, 5 insertions, 2 deletions
diff --git a/VERSION b/VERSION
index 2317587..c72cf6b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.105
+0.1.107
diff --git a/props.h b/props.h
index 01b47e6..3f1dd99 100644
--- a/props.h
+++ b/props.h
@@ -124,9 +124,12 @@ struct _props_t {
props_impl_t impls [1];
};
+#define NEXT_POWER_OF_2(x) \
+ ( ( (x) <= 2 ) ? (x) : ( 1 << ( 32 - __builtin_clz( (x) - 1 ) ) ) )
+
#define PROPS_T(PROPS, MAX_NIMPLS) \
props_t (PROPS); \
- props_impl_t _impls [MAX_NIMPLS]
+ props_impl_t _impls [NEXT_POWER_OF_2(MAX_NIMPLS) - 1]
// rt-safe
static inline int