Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: sky/engine/wtf/BitwiseOperations.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/wtf/BitwiseOperations.h
diff --git a/sky/engine/wtf/BitwiseOperations.h b/sky/engine/wtf/BitwiseOperations.h
index 41c14acde04338fc8d8990d24aa2e161fd25649e..4808efeda69644639885964bba564a44a2477001 100644
--- a/sky/engine/wtf/BitwiseOperations.h
+++ b/sky/engine/wtf/BitwiseOperations.h
@@ -42,9 +42,32 @@
#include <stdint.h>
+#if COMPILER(MSVC)
+#include <intrin.h>
+#endif
+
namespace WTF {
-#if COMPILER(GCC)
+#if COMPILER(MSVC)
+
+ALWAYS_INLINE uint32_t countLeadingZeros32(uint32_t x)
+{
+ unsigned long index;
+ return LIKELY(_BitScanReverse(&index, x)) ? (31 - index) : 32;
+}
+
+#if CPU(64BIT)
+
+// MSVC only supplies _BitScanForward64 when building for a 64-bit target.
+ALWAYS_INLINE uint64_t countLeadingZeros64(uint64_t x)
+{
+ unsigned long index;
+ return LIKELY(_BitScanReverse64(&index, x)) ? (63 - index) : 64;
+}
+
+#endif
+
+#elif COMPILER(GCC)
// This is very annoying. __builtin_clz has undefined behaviour for an input of
// 0, even though these's clearly a return value that makes sense, and even
« no previous file with comments | « sky/engine/wtf/BUILD.gn ('k') | sky/engine/wtf/ByteSwap.h » ('j') | sky/engine/wtf/Compiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698