Created
April 27, 2014 00:30
-
-
Save astiob/11334702 to your computer and use it in GitHub Desktop.
11rcombs/libass/rasterizer: MSVC ilog2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3183dff76442ac06e4fb19fd2f7be99a34d18522 Mon Sep 17 00:00:00 2001 | |
From: Oleg Oshmyan <[email protected]> | |
Date: Sun, 27 Apr 2014 01:28:59 +0100 | |
Subject: [PATCH] MSVC ilog2 | |
--- | |
libass/ass_rasterizer.c | 9 +++++++++ | |
1 file changed, 9 insertions(+) | |
diff --git a/libass/ass_rasterizer.c b/libass/ass_rasterizer.c | |
index 7baf91f..8cdbfd0 100644 | |
--- a/libass/ass_rasterizer.c | |
+++ b/libass/ass_rasterizer.c | |
@@ -20,12 +20,21 @@ | |
#include "ass_rasterizer.h" | |
#include <assert.h> | |
+#ifdef _MSC_VER | |
+#include <intrin.h> | |
+#pragma intrinsic(_BitScanReverse) | |
+#endif | |
+ | |
static inline int ilog2(uint32_t n) // XXX: different compilers | |
{ | |
#ifdef __GNUC__ | |
return __builtin_clz(n) ^ 31; | |
+#elif defined(_MSC_VER) | |
+ int res; | |
+ _BitScanReverse(&res, n); | |
+ return res; | |
#else | |
int res = 0; | |
for (int ord = 16; ord; ord /= 2) | |
-- | |
1.9.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment