X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Fasm-i386%2Fbitops.h;h=8fd938fa988687c97c7696ed70152011c999daa9;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=2c6a7bb1e0cee1e0565bb1a57d927048081e4d67;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 2c6a7bb1e..8fd938fa9 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -34,7 +34,7 @@ * Note that @nr may be almost arbitrarily large; this function is not * restricted to acting on a single-word quantity. */ -static __inline__ void set_bit(int nr, volatile unsigned long * addr) +static inline void set_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( LOCK_PREFIX "btsl %1,%0" @@ -51,7 +51,7 @@ static __inline__ void set_bit(int nr, volatile unsigned long * addr) * If it's called on the same region of memory simultaneously, the effect * may be that only one operation succeeds. */ -static __inline__ void __set_bit(int nr, volatile unsigned long * addr) +static inline void __set_bit(int nr, volatile unsigned long * addr) { __asm__( "btsl %1,%0" @@ -69,7 +69,7 @@ static __inline__ void __set_bit(int nr, volatile unsigned long * addr) * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() * in order to ensure changes are visible on other processors. */ -static __inline__ void clear_bit(int nr, volatile unsigned long * addr) +static inline void clear_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( LOCK_PREFIX "btrl %1,%0" @@ -77,7 +77,7 @@ static __inline__ void clear_bit(int nr, volatile unsigned long * addr) :"Ir" (nr)); } -static __inline__ void __clear_bit(int nr, volatile unsigned long * addr) +static inline void __clear_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( "btrl %1,%0" @@ -96,7 +96,7 @@ static __inline__ void __clear_bit(int nr, volatile unsigned long * addr) * If it's called on the same region of memory simultaneously, the effect * may be that only one operation succeeds. */ -static __inline__ void __change_bit(int nr, volatile unsigned long * addr) +static inline void __change_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( "btcl %1,%0" @@ -113,7 +113,7 @@ static __inline__ void __change_bit(int nr, volatile unsigned long * addr) * Note that @nr may be almost arbitrarily large; this function is not * restricted to acting on a single-word quantity. */ -static __inline__ void change_bit(int nr, volatile unsigned long * addr) +static inline void change_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( LOCK_PREFIX "btcl %1,%0" @@ -129,7 +129,7 @@ static __inline__ void change_bit(int nr, volatile unsigned long * addr) * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr) +static inline int test_and_set_bit(int nr, volatile unsigned long * addr) { int oldbit; @@ -149,7 +149,7 @@ static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr) * If two examples of this operation race, one can appear to succeed * but actually fail. You must protect multiple accesses with a lock. */ -static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * addr) +static inline int __test_and_set_bit(int nr, volatile unsigned long * addr) { int oldbit; @@ -168,7 +168,7 @@ static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * addr) * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr) +static inline int test_and_clear_bit(int nr, volatile unsigned long * addr) { int oldbit; @@ -188,7 +188,7 @@ static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr) * If two examples of this operation race, one can appear to succeed * but actually fail. You must protect multiple accesses with a lock. */ -static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr) +static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) { int oldbit; @@ -200,7 +200,7 @@ static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr) } /* WARNING: non atomic and it can be reordered! */ -static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr) +static inline int __test_and_change_bit(int nr, volatile unsigned long *addr) { int oldbit; @@ -219,7 +219,7 @@ static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static __inline__ int test_and_change_bit(int nr, volatile unsigned long* addr) +static inline int test_and_change_bit(int nr, volatile unsigned long* addr) { int oldbit; @@ -244,7 +244,7 @@ static inline int constant_test_bit(int nr, const volatile unsigned long *addr) return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0; } -static __inline__ int variable_test_bit(int nr, const volatile unsigned long * addr) +static inline int variable_test_bit(int nr, const volatile unsigned long * addr) { int oldbit; @@ -270,7 +270,7 @@ static __inline__ int variable_test_bit(int nr, const volatile unsigned long * a * Returns the bit-number of the first zero bit, not the number of the byte * containing a bit. */ -static __inline__ int find_first_zero_bit(const unsigned long *addr, unsigned size) +static inline int find_first_zero_bit(const unsigned long *addr, unsigned size) { int d0, d1, d2; int res; @@ -294,6 +294,14 @@ static __inline__ int find_first_zero_bit(const unsigned long *addr, unsigned si return res; } +/** + * find_next_zero_bit - find the first zero bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The maximum size to search + */ +int find_next_zero_bit(const unsigned long *addr, int size, int offset); + /** * find_first_bit - find the first set bit in a memory region * @addr: The address to start the search at @@ -302,7 +310,7 @@ static __inline__ int find_first_zero_bit(const unsigned long *addr, unsigned si * Returns the bit-number of the first set bit, not the number of the byte * containing a bit. */ -static __inline__ int find_first_bit(const unsigned long *addr, unsigned size) +static inline int find_first_bit(const unsigned long *addr, unsigned size) { int d0, d1; int res; @@ -322,71 +330,13 @@ static __inline__ int find_first_bit(const unsigned long *addr, unsigned size) return res; } -/** - * find_next_zero_bit - find the first zero bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The maximum size to search - */ -static __inline__ int find_next_zero_bit(const unsigned long *addr, int size, int offset) -{ - unsigned long * p = ((unsigned long *) addr) + (offset >> 5); - int set = 0, bit = offset & 31, res; - - if (bit) { - /* - * Look for zero in the first 32 bits. - */ - __asm__("bsfl %1,%0\n\t" - "jne 1f\n\t" - "movl $32, %0\n" - "1:" - : "=r" (set) - : "r" (~(*p >> bit))); - if (set < (32 - bit)) - return set + offset; - set = 32 - bit; - p++; - } - /* - * No zero yet, search remaining full bytes for a zero - */ - res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr)); - return (offset + set + res); -} - /** * find_next_bit - find the first set bit in a memory region * @addr: The address to base the search on * @offset: The bitnumber to start searching at * @size: The maximum size to search */ -static __inline__ int find_next_bit(const unsigned long *addr, int size, int offset) -{ - const unsigned long *p = addr + (offset >> 5); - int set = 0, bit = offset & 31, res; - - if (bit) { - /* - * Look for nonzero in the first 32 bits: - */ - __asm__("bsfl %1,%0\n\t" - "jne 1f\n\t" - "movl $32, %0\n" - "1:" - : "=r" (set) - : "r" (*p >> bit)); - if (set < (32 - bit)) - return set + offset; - set = 32 - bit; - p++; - } - /* - * No set bit yet, search remaining full words for a bit - */ - res = find_first_bit (p, size - 32 * (p - addr)); - return (offset + set + res); -} +int find_next_bit(const unsigned long *addr, int size, int offset); /** * ffz - find first zero in word. @@ -394,7 +344,7 @@ static __inline__ int find_next_bit(const unsigned long *addr, int size, int off * * Undefined if no zero exists, so code should check against ~0UL first. */ -static __inline__ unsigned long ffz(unsigned long word) +static inline unsigned long ffz(unsigned long word) { __asm__("bsfl %1,%0" :"=r" (word) @@ -408,7 +358,7 @@ static __inline__ unsigned long ffz(unsigned long word) * * Undefined if no bit exists, so code should check against 0 first. */ -static __inline__ unsigned long __ffs(unsigned long word) +static inline unsigned long __ffs(unsigned long word) { __asm__("bsfl %1,%0" :"=r" (word) @@ -451,7 +401,7 @@ static inline int sched_find_first_bit(const unsigned long *b) * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). */ -static __inline__ int ffs(int x) +static inline int ffs(int x) { int r;