summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2014-09-29 22:15:31 (GMT)
committerJason Evans <jasone@canonware.com>2014-09-29 22:15:31 (GMT)
commit5d9732f2cf03e8f1639e20eb327100480b3f96dc (patch)
treec630709b49c8dfcf23161b61829beccce48f6986
parente3a16fce5eb0c62a49e751f156d040c9f77fbc23 (diff)
parent112704cfbfacfc9cecdfb732741df47eb4133902 (diff)
downloadjemalloc-5d9732f2cf03e8f1639e20eb327100480b3f96dc.zip
jemalloc-5d9732f2cf03e8f1639e20eb327100480b3f96dc.tar.gz
jemalloc-5d9732f2cf03e8f1639e20eb327100480b3f96dc.tar.bz2
Merge pull request #129 from daverigby/msvc_lg_floor
Use MSVC intrinsics for lg_floor
-rw-r--r--include/jemalloc/internal/util.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/jemalloc/internal/util.h b/include/jemalloc/internal/util.h
index cc7806d..5af6832 100644
--- a/include/jemalloc/internal/util.h
+++ b/include/jemalloc/internal/util.h
@@ -176,6 +176,21 @@ lg_floor(size_t x)
);
return (ret);
}
+#elif (defined(_MSC_VER))
+JEMALLOC_INLINE size_t
+lg_floor(size_t x)
+{
+ unsigned long ret;
+
+#if (LG_SIZEOF_PTR == 3)
+ _BitScanReverse64(&ret, x);
+#elif (LG_SIZEOF_PTR == 2)
+ _BitScanReverse(&ret, x);
+#else
+# error "Unsupported type sizes for lg_floor()"
+#endif
+ return (ret);
+}
#elif (defined(JEMALLOC_HAVE_BUILTIN_CLZ))
JEMALLOC_INLINE size_t
lg_floor(size_t x)