Uninline the non-leaf bit search functions. Saves 9 kbytes from my vmlinux. And gratuitously s/__inline__/inline/ Signed-off-by: Andrew Morton --- 25-akpm/arch/i386/lib/Makefile | 5 - 25-akpm/arch/i386/lib/bitops.c | 70 +++++++++++++++++++++++++ 25-akpm/include/asm-i386/bitops.h | 104 +++++++++----------------------------- 3 files changed, 99 insertions(+), 80 deletions(-) diff -puN include/asm-i386/bitops.h~i386-uninline-bitops include/asm-i386/bitops.h --- 25/include/asm-i386/bitops.h~i386-uninline-bitops 2004-06-03 21:15:16.703893400 -0700 +++ 25-akpm/include/asm-i386/bitops.h 2004-06-03 21:15:16.710892336 -0700 @@ -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, v * 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, * 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, :"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 n * 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 * 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 * 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(i * 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 * 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 * 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_b } /* 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_ * 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 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( * 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; @@ -295,6 +295,14 @@ static __inline__ int find_first_zero_bi } /** + * 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 * @size: The maximum size to search @@ -302,7 +310,7 @@ static __inline__ int find_first_zero_bi * 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; @@ -323,70 +331,12 @@ static __inline__ int find_first_bit(con } /** - * 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(cons * * 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(unsi * * 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(c * 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; diff -puN /dev/null arch/i386/lib/bitops.c --- /dev/null 2003-09-15 06:40:47.000000000 -0700 +++ 25-akpm/arch/i386/lib/bitops.c 2004-06-03 21:15:16.710892336 -0700 @@ -0,0 +1,70 @@ +#include +#include + +/** + * 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 + */ +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); +} +EXPORT_SYMBOL(find_next_bit); + +/** + * 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) +{ + 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); +} +EXPORT_SYMBOL(find_next_zero_bit); diff -puN arch/i386/lib/Makefile~i386-uninline-bitops arch/i386/lib/Makefile --- 25/arch/i386/lib/Makefile~i386-uninline-bitops 2004-06-03 21:15:16.704893248 -0700 +++ 25-akpm/arch/i386/lib/Makefile 2004-06-03 21:15:16.711892184 -0700 @@ -3,9 +3,8 @@ # -lib-y = checksum.o delay.o \ - usercopy.o getuser.o \ - memcpy.o strstr.o +lib-y = checksum.o delay.o usercopy.o getuser.o memcpy.o strstr.o \ + bitops.o lib-$(CONFIG_X86_USE_3DNOW) += mmx.o lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o _