From 9eeec09ebe92e647ab53ce0822d433e531ed4179 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 21 Sep 2012 09:34:31 +0200 Subject: [PATCH] Fix log2 and alignment calculation - 64bit issue --- base/include/util/misc_math.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/include/util/misc_math.h b/base/include/util/misc_math.h index 6efc32e29a..8c4b654013 100644 --- a/base/include/util/misc_math.h +++ b/base/include/util/misc_math.h @@ -31,15 +31,15 @@ namespace Genode { */ template static inline T _align_mask(T align) { - return ~((1 << align) - 1); } + return ~(((T)1 << align) - 1); } template static inline T _align_offset(T align) { - return (1 << align) - 1; } + return ((T)1 << align) - 1; } template static inline T align_addr(T addr, int align) { - return (addr + _align_offset(align)) & _align_mask(align); } + return (addr + _align_offset(align)) & _align_mask((T)align); } /** @@ -52,7 +52,7 @@ namespace Genode { { if (!value) return -1; for (int i = 8 * sizeof(value) - 1; i >= 0; --i) - if ((1 << i) & value) return i; + if (((T)1 << i) & value) return i; return -1; }