From fe3a54d7fd8c85960fed04d28d5dedbc1d94845d Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 5 Mar 2013 15:48:57 -0600 Subject: [PATCH] Buildfix! --- Source/Core/Common/Src/MathUtil.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h index c6c29ff368..ec9c9cc8a3 100644 --- a/Source/Core/Common/Src/MathUtil.h +++ b/Source/Core/Common/Src/MathUtil.h @@ -152,18 +152,17 @@ float MathFloatVectorSum(const std::vector&); #define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) #define ROUND_DOWN(x, a) ((x) & ~((a) - 1)) -template -T Log2(T val) +// Rounds down. 0 -> undefined +inline u64 Log2(u64 val) { -#if defined(_M_X64) - T result; - asm - ( - "bsr %1, %0" - : "=r"(result) - : "r"(val) - ); +#if defined(__GNUC__) + return 63 - __builtin_clzll(val); + +#elif defined(_MSC_VER) + unsigned long result = -1; + _BitScanReverse64(&result, val); return result; + #else T result = -1; while (val != 0)