From 88e36f272b54c6dacc4d267ee322c8e1ee3129cc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 7 Nov 2016 22:15:00 -0500 Subject: [PATCH] fix calculation of log2i(1) --- include/villas/utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/villas/utils.h b/include/villas/utils.h index 0e29fba8e..e6ef0e469 100644 --- a/include/villas/utils.h +++ b/include/villas/utils.h @@ -221,7 +221,8 @@ __attribute__((always_inline)) static inline uint64_t rdtsc() /** Get log2 of long long integers */ static inline int log2i(long long x) { - assert(x > 0); + if (x == 0) + return 1; return sizeof(x) * 8 - __builtin_clzll(x) - 1; }