From 33db37e66923ef90a4071910eea06c79c077cc15 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 5 Apr 2019 15:28:08 -0400 Subject: [PATCH 1/2] common/bit_util: Make CountLeading/CountTrailing functions have the same return types Makes the return type consistently uniform (like the intrinsics we're wrapping). This also conveniently silences a truncation warning within the kernel multi_level_queue. --- src/common/bit_util.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/bit_util.h b/src/common/bit_util.h index a4f9ed4aad..d032df4131 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -32,7 +32,7 @@ inline u32 CountLeadingZeroes32(u32 value) { return 32; } -inline u64 CountLeadingZeroes64(u64 value) { +inline u32 CountLeadingZeroes64(u64 value) { unsigned long leading_zero = 0; if (_BitScanReverse64(&leading_zero, value) != 0) { @@ -47,15 +47,15 @@ inline u32 CountLeadingZeroes32(u32 value) { return 32; } - return __builtin_clz(value); + return static_cast(__builtin_clz(value)); } -inline u64 CountLeadingZeroes64(u64 value) { +inline u32 CountLeadingZeroes64(u64 value) { if (value == 0) { return 64; } - return __builtin_clzll(value); + return static_cast(__builtin_clzll(value)); } #endif @@ -70,7 +70,7 @@ inline u32 CountTrailingZeroes32(u32 value) { return 32; } -inline u64 CountTrailingZeroes64(u64 value) { +inline u32 CountTrailingZeroes64(u64 value) { unsigned long trailing_zero = 0; if (_BitScanForward64(&trailing_zero, value) != 0) { @@ -85,15 +85,15 @@ inline u32 CountTrailingZeroes32(u32 value) { return 32; } - return __builtin_ctz(value); + return static_cast(__builtin_ctz(value)); } -inline u64 CountTrailingZeroes64(u64 value) { +inline u32 CountTrailingZeroes64(u64 value) { if (value == 0) { return 64; } - return __builtin_ctzll(value); + return static_cast(__builtin_ctzll(value)); } #endif From 93b84e9308935cdd228df43febab577edd75480d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 5 Apr 2019 15:31:56 -0400 Subject: [PATCH 2/2] common/multi_level_queue: Silence truncation warning in iterator operator++ --- src/common/multi_level_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/multi_level_queue.h b/src/common/multi_level_queue.h index 2b61b91e06..9cb448f567 100644 --- a/src/common/multi_level_queue.h +++ b/src/common/multi_level_queue.h @@ -72,7 +72,7 @@ public: u64 prios = mlq.used_priorities; prios &= ~((1ULL << (current_priority + 1)) - 1); if (prios == 0) { - current_priority = mlq.depth(); + current_priority = static_cast(mlq.depth()); } else { current_priority = CountTrailingZeroes64(prios); it = GetBeginItForPrio();