summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Rigby <daver@couchbase.com>2014-09-22 14:54:33 (GMT)
committerDave Rigby <daver@couchbase.com>2014-09-24 10:55:02 (GMT)
commit112704cfbfacfc9cecdfb732741df47eb4133902 (patch)
tree28b2e17230fe974cd7b6c3c839ad91c83d7edd82
parenteb5376ab9e61d96daa0d1f03b4474baf5232478f (diff)
downloadjemalloc-112704cfbfacfc9cecdfb732741df47eb4133902.zip
jemalloc-112704cfbfacfc9cecdfb732741df47eb4133902.tar.gz
jemalloc-112704cfbfacfc9cecdfb732741df47eb4133902.tar.bz2
Use MSVC intrinsics for lg_floor
When using MSVC make use of its intrinsic functions (supported on x86, amd64 & ARM) 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)