From: Christopher Dykes Date: Wed, 4 May 2016 17:28:49 +0000 (-0700) Subject: Implement __builtin_ctzll for MSVC X-Git-Tag: 2016.07.26~282 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f79d6393cfd203d7293ac634328e36a7673c34e9;p=folly.git 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 --- 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);