1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Bit scan reverse
6 // This code has been put into the public domain.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 ///////////////////////////////////////////////////////////////////////////////
17 // NOTE: Both input and output variables for lzma_bsr must be uint32_t.
19 #if defined(__GNUC__) && (defined (HAVE_ASM_X86) || defined(HAVE_ASM_X86_64))
20 # define lzma_bsr(dest, n) \
21 __asm__("bsrl %1, %0" : "=r" (dest) : "rm" (n))
24 # define lzma_bsr(dest, n) dest = lzma_bsr_helper(n)
26 static inline uint32_t
27 lzma_bsr_helper(uint32_t n)
33 if ((n & UINT32_C(0xFFFF0000)) == 0) {
38 if ((n & UINT32_C(0xFF000000)) == 0) {
43 if ((n & UINT32_C(0xF0000000)) == 0) {
48 if ((n & UINT32_C(0xC0000000)) == 0) {
53 if ((n & UINT32_C(0x80000000)) == 0)