Commit 9cf96558 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

add __builtin_ctz and __builtin_ctzl

Summary: Add missing WIN32 compat builtins

Reviewed By: Orvid

Differential Revision: D7276240

fbshipit-source-id: 094c0861126b3477e9112987f033edacbde4aca4
parent 3c047a7b
...@@ -55,6 +55,15 @@ FOLLY_ALWAYS_INLINE int __builtin_clzll(unsigned long long x) { ...@@ -55,6 +55,15 @@ FOLLY_ALWAYS_INLINE int __builtin_clzll(unsigned long long x) {
return int(_BitScanReverse64(&index, x) ? 63 - index : 64); return int(_BitScanReverse64(&index, x) ? 63 - index : 64);
} }
FOLLY_ALWAYS_INLINE int __builtin_ctz(unsigned int x) {
unsigned long index;
return int(_BitScanForward(&index, (unsigned long)x) ? index : 32);
}
FOLLY_ALWAYS_INLINE int __builtin_ctzl(unsigned long x) {
return __builtin_ctz((unsigned int)x);
}
FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) { FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) {
unsigned long index; unsigned long index;
return int(_BitScanForward64(&index, x) ? index : 64); return int(_BitScanForward64(&index, x) ? index : 64);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment