After this has been brought up many times before, rename src/arch/i386 to
[coreboot.git] / src / arch / x86 / include / bitops.h
1 #ifndef I386_BITOPS_H
2 #define I386_BITOPS_H
3
4 /**
5  * log2 - Find the truncated log base 2 of x
6  */
7
8 static inline unsigned long log2(unsigned long x)
9 {
10         unsigned long r = 0;
11         __asm__(
12                 "bsrl %1, %0\n\t"
13                 "jnz 1f\n\t"
14                 "movl $-1, %0\n\t"
15                 "1:\n\t"
16                 : "=r" (r) : "r" (x));
17         return r;
18
19 }
20 #endif /* I386_BITOPS_H */