tsan: relax checking of errno spoiling in signal handlers
[blocksruntime.git] / lib / ffsdi2.c
bloba5ac9900ff10b2bed041be23db02db5506ca822e
1 /* ===-- ffsdi2.c - Implement __ffsdi2 -------------------------------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file implements __ffsdi2 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
15 #include "int_lib.h"
17 /* Returns: the index of the least significant 1-bit in a, or
18 * the value zero if a is zero. The least significant bit is index one.
21 COMPILER_RT_ABI si_int
22 __ffsdi2(di_int a)
24 dwords x;
25 x.all = a;
26 if (x.s.low == 0)
28 if (x.s.high == 0)
29 return 0;
30 return __builtin_ctz(x.s.high) + (1 + sizeof(si_int) * CHAR_BIT);
32 return __builtin_ctz(x.s.low) + 1;