Use generic ffs() / __builtin_ffs() if supported by the compiler. GCC 16
will have support for __builtin_ffs().
See gcc commit
f50cff9766c5 ("s390: Implement clz and ctz for SI mode").
In the distant future when GCC 16 becomes the minimum supported version,
this allows to get rid of the flogr inline assembly.
Kernel image size is reduced by ~500 bytes (gcc 16 beta + 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>
depends on KASAN
default 0x1C000000000000
+config CC_HAS_BUILTIN_FFS
+ def_bool !(CC_IS_GCC && GCC_VERSION < 160000)
+ help
+ GCC versions before 16.0.0 generate library calls to ffs()
+ for __builtin_ffs() even when __has_builtin(__builtin_ffs)
+ is true.
+
config CC_ASM_FLAG_OUTPUT_BROKEN
def_bool CC_IS_GCC && GCC_VERSION < 140200
help
return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
}
+#ifndef CONFIG_CC_HAS_BUILTIN_FFS
+
/**
* __flogr - find leftmost one
* @word - The word to search
return BITS_PER_LONG - __flogr(-val & val);
}
+#else /* CONFIG_CC_HAS_BUILTIN_FFS */
+
+#include <asm-generic/bitops/builtin-ffs.h>
+
+#endif /* CONFIG_CC_HAS_BUILTIN_FFS */
+
#include <asm-generic/bitops/builtin-__ffs.h>
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/builtin-__fls.h>