From f79d6393cfd203d7293ac634328e36a7673c34e9 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Wed, 4 May 2016 10:28:49 -0700 Subject: [PATCH] Implement __builtin_ctzll for MSVC Summary: MSVC doesn't have it, but Folly uses it, so implement it in the Builtins portability header. Reviewed By: yfeldblum Differential Revision: D3256123 fb-gh-sync-id: fd9ea1b6098d97cf1fde4732905bae9bde8cd8ad fbshipit-source-id: fd9ea1b6098d97cf1fde4732905bae9bde8cd8ad --- folly/portability/Builtins.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/folly/portability/Builtins.h b/folly/portability/Builtins.h index 959ce5c2..567ca6e9 100755 --- a/folly/portability/Builtins.h +++ b/folly/portability/Builtins.h @@ -35,6 +35,11 @@ FOLLY_ALWAYS_INLINE int __builtin_clzll(unsigned long long x) { return (int)(_BitScanReverse64(&index, x) ? 63 - index : 64); } +FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) { + unsigned long index; + return (int)(_BitScanForward64(&index, x) ? index : 64); +} + FOLLY_ALWAYS_INLINE int __builtin_ffs(int x) { unsigned long index; return (int)(_BitScanForward(&index, (unsigned long)x) ? index : 0); -- 2.34.1