X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=include%2Fasm-powerpc%2Fbitops.h;h=8f757f6246e4effe36e790c811dd0b7939f4d875;hb=8389998ae9ea2888c86c446f7911ddced50052a1;hp=76e2f08c3c83016915a7831e3402a6baa638284d;hpb=c0bc8721b8d0380ec69fa97578c91201201b05a9;p=linux-2.6-omap-h63xx.git diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h index 76e2f08c3c8..8f757f6246e 100644 --- a/include/asm-powerpc/bitops.h +++ b/include/asm-powerpc/bitops.h @@ -65,8 +65,8 @@ static __inline__ void set_bit(int nr, volatile unsigned long *addr) PPC405_ERR77(0,%3) PPC_STLCX "%0,0,%3\n" "bne- 1b" - : "=&r"(old), "=m"(*p) - : "r"(mask), "r"(p), "m"(*p) + : "=&r" (old), "+m" (*p) + : "r" (mask), "r" (p) : "cc" ); } @@ -82,8 +82,8 @@ static __inline__ void clear_bit(int nr, volatile unsigned long *addr) PPC405_ERR77(0,%3) PPC_STLCX "%0,0,%3\n" "bne- 1b" - : "=&r"(old), "=m"(*p) - : "r"(mask), "r"(p), "m"(*p) + : "=&r" (old), "+m" (*p) + : "r" (mask), "r" (p) : "cc" ); } @@ -99,8 +99,8 @@ static __inline__ void change_bit(int nr, volatile unsigned long *addr) PPC405_ERR77(0,%3) PPC_STLCX "%0,0,%3\n" "bne- 1b" - : "=&r"(old), "=m"(*p) - : "r"(mask), "r"(p), "m"(*p) + : "=&r" (old), "+m" (*p) + : "r" (mask), "r" (p) : "cc" ); } @@ -179,8 +179,8 @@ static __inline__ void set_bits(unsigned long mask, unsigned long *addr) "or %0,%0,%2\n" PPC_STLCX "%0,0,%3\n" "bne- 1b" - : "=&r" (old), "=m" (*addr) - : "r" (mask), "r" (addr), "m" (*addr) + : "=&r" (old), "+m" (*addr) + : "r" (mask), "r" (addr) : "cc"); } @@ -190,7 +190,8 @@ static __inline__ void set_bits(unsigned long mask, unsigned long *addr) * Return the zero-based bit position (LE, not IBM bit numbering) of * the most significant 1-bit in a double word. */ -static __inline__ int __ilog2(unsigned long x) +static __inline__ __attribute__((const)) +int __ilog2(unsigned long x) { int lz; @@ -198,6 +199,24 @@ static __inline__ int __ilog2(unsigned long x) return BITS_PER_LONG - 1 - lz; } +static inline __attribute__((const)) +int __ilog2_u32(u32 n) +{ + int bit; + asm ("cntlzw %0,%1" : "=r" (bit) : "r" (n)); + return 31 - bit; +} + +#ifdef __powerpc64__ +static inline __attribute__((const)) +int __ilog2_u64(u64 n) +{ + int bit; + asm ("cntlzd %0,%1" : "=r" (bit) : "r" (n)); + return 63 - bit; +} +#endif + /* * Determines the bit position of the least significant 0 bit in the * specified double word. The returned bit position will be