diff --git a/include/villas/utils.h b/include/villas/utils.h index c10ca0b97..5e8933222 100644 --- a/include/villas/utils.h +++ b/include/villas/utils.h @@ -62,12 +62,6 @@ /** Check if the number is a power of 2 */ #define IS_POW2(x) (((x) != 0) && !((x) & ((x) - 1))) -/** Get nearest up-rounded power of 2 */ -#define LOG2_CEIL(x) (1 << (log2i((x) - 1) + 1)) - -/** Check if the number is a power of 2 */ -#define IS_POW2(x) (((x) != 0) && !((x) & ((x) - 1))) - /** Calculate the number of elements in an array. */ #define ARRAY_LEN(a) ( sizeof (a) / sizeof (a)[0] ) diff --git a/lib/queue.c b/lib/queue.c index 15d3b8996..20a7a6710 100644 --- a/lib/queue.c +++ b/lib/queue.c @@ -39,8 +39,11 @@ int queue_init(struct queue *q, size_t size, const struct memtype *mem) { /* Queue size must be 2 exponent */ - if (!IS_POW2(size)) - return -1; + if (!IS_POW2(size)) { + size_t old_size = size; + size = LOG2_CEIL(size); + warn("A queue size was changed from %lu to %lu", old_size, size); + } q->mem = mem; q->buffer_mask = size - 1;