Commit fcd39524 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 0

Fix the ffs builtins under MSVC

Summary: I was off by one in my implementation.

Reviewed By: yfeldblum

Differential Revision: D3651183

fbshipit-source-id: 4d6a6d08c06bce332a00088920bf604a10c942e7
parent 0b400104
......@@ -42,14 +42,14 @@ FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) {
FOLLY_ALWAYS_INLINE int __builtin_ffs(int x) {
unsigned long index;
return (int)(_BitScanForward(&index, (unsigned long)x) ? index : 0);
return (int)(_BitScanForward(&index, (unsigned long)x) ? index + 1 : 0);
}
FOLLY_ALWAYS_INLINE int __builtin_ffsl(long x) { return __builtin_ffs((int)x); }
FOLLY_ALWAYS_INLINE int __builtin_ffsll(long long x) {
unsigned long index;
return (int)(_BitScanForward64(&index, (unsigned long long)x) ? index : 0);
return (int)(_BitScanForward64(&index, (unsigned long long)x) ? index + 1 : 0);
}
FOLLY_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x) {
......
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