Skip to content

Commit 7b80a23

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/bitops: Switch to generic fls(), fls64(), etc.
Switch to generic fls(), fls64(), etc. which are implemented with __builtin_ctzl(), __builtin_clzl(). Those builtins are available for all supported compilers. Kernel image size is reduced by ~10kb (gcc 15.1.0 + defconfig). Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 5671ce2 commit 7b80a23

1 file changed

Lines changed: 5 additions & 51 deletions

File tree

arch/s390/include/asm/bitops.h

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,6 @@ static __always_inline __attribute_const__ unsigned long __flogr(unsigned long w
180180
}
181181
}
182182

183-
/**
184-
* __ffs - find first bit in word.
185-
* @word: The word to search
186-
*
187-
* Undefined if no bit exists, so code should check against 0 first.
188-
*/
189-
static __always_inline __flatten unsigned long __ffs(unsigned long word)
190-
{
191-
return __flogr(-word & word) ^ (BITS_PER_LONG - 1);
192-
}
193-
194183
/**
195184
* ffs - find first bit set
196185
* @word: the word to search
@@ -205,48 +194,13 @@ static __always_inline __flatten int ffs(int word)
205194
return BITS_PER_LONG - __flogr(-val & val);
206195
}
207196

208-
/**
209-
* __fls - find last (most-significant) set bit in a long word
210-
* @word: the word to search
211-
*
212-
* Undefined if no set bit exists, so code should check against 0 first.
213-
*/
214-
static __always_inline __flatten unsigned long __fls(unsigned long word)
215-
{
216-
return __flogr(word) ^ (BITS_PER_LONG - 1);
217-
}
218-
219-
/**
220-
* fls64 - find last set bit in a 64-bit word
221-
* @word: the word to search
222-
*
223-
* This is defined in a similar way as the libc and compiler builtin
224-
* ffsll, but returns the position of the most significant set bit.
225-
*
226-
* fls64(value) returns 0 if value is 0 or the position of the last
227-
* set bit if value is nonzero. The last (most significant) bit is
228-
* at position 64.
229-
*/
230-
static __always_inline __flatten int fls64(unsigned long word)
231-
{
232-
return BITS_PER_LONG - __flogr(word);
233-
}
234-
235-
/**
236-
* fls - find last (most-significant) bit set
237-
* @word: the word to search
238-
*
239-
* This is defined the same way as ffs.
240-
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
241-
*/
242-
static __always_inline __flatten int fls(unsigned int word)
243-
{
244-
return fls64(word);
245-
}
246-
197+
#include <asm-generic/bitops/builtin-__ffs.h>
198+
#include <asm-generic/bitops/ffz.h>
199+
#include <asm-generic/bitops/builtin-__fls.h>
200+
#include <asm-generic/bitops/builtin-fls.h>
201+
#include <asm-generic/bitops/fls64.h>
247202
#include <asm/arch_hweight.h>
248203
#include <asm-generic/bitops/const_hweight.h>
249-
#include <asm-generic/bitops/ffz.h>
250204
#include <asm-generic/bitops/sched.h>
251205
#include <asm-generic/bitops/le.h>
252206
#include <asm-generic/bitops/ext2-atomic-setbit.h>

0 commit comments

Comments
 (0)