1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Bit scan reverse
6 // Author: Lasse Collin
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
16 // NOTE: Both input and output variables for lzma_bsr must be uint32_t.
18 #if defined(__GNUC__) && (defined (HAVE_ASM_X86) || defined(HAVE_ASM_X86_64))
19 # define lzma_bsr(dest, n) \
20 __asm__("bsrl %1, %0" : "=r" (dest) : "rm" (n))
23 # define lzma_bsr(dest, n) dest = lzma_bsr_helper(n)
25 static inline uint32_t
26 lzma_bsr_helper(uint32_t n)
32 if ((n & UINT32_C(0xFFFF0000)) == 0) {
37 if ((n & UINT32_C(0xFF000000)) == 0) {
42 if ((n & UINT32_C(0xF0000000)) == 0) {
47 if ((n & UINT32_C(0xC0000000)) == 0) {
52 if ((n & UINT32_C(0x80000000)) == 0)