linux/arch/csky/include/asm
Kees Cook 4452a0dfc5 csky: Add __attribute_const__ to ffs()-family implementations
While tracking down a problem where constant expressions used by
BUILD_BUG_ON() suddenly stopped working[1], we found that an added static
initializer was convincing the compiler that it couldn't track the state
of the prior statically initialized value. Tracing this down found that
ffs() was used in the initializer macro, but since it wasn't marked with
__attribute__const__, the compiler had to assume the function might
change variable states as a side-effect (which is not true for ffs(),
which provides deterministic math results).

Add missing __attribute_const__ annotations to C-SKY's implementations of
ffs(), __ffs(), fls(), and __fls() functions. These are pure mathematical
functions that always return the same result for the same input with no
side effects, making them eligible for compiler optimization.

Build tested ARCH=csky defconfig with GCC csky-linux 15.1.0.

Link: https://github.com/KSPP/linux/issues/364 [1]
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250804164417.1612371-3-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
2025-09-08 14:58:50 -07:00
..
Kbuild asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
addrspace.h
asid.h
atomic.h
barrier.h
bitops.h csky: Add __attribute_const__ to ffs()-family implementations 2025-09-08 14:58:50 -07:00
bug.h
cache.h
cacheflush.h
cachetype.h Introduce cpu_dcache_is_aliasing() across all architectures 2024-02-22 15:27:19 -08:00
checksum.h
clocksource.h
cmpxchg.h csky: Emulate one-byte cmpxchg 2024-05-11 07:07:07 -07:00
elf.h
fixmap.h
ftrace.h function_graph: Everyone uses HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, remove it 2024-06-11 11:18:24 -04:00
futex.h
highmem.h
io.h mm/ioremap: pass pgprot_t to ioremap_prot() instead of unsigned long 2025-03-16 22:06:23 -07:00
irq_work.h arch: consolidate arch_irq_work_raise prototypes 2023-11-23 11:32:29 +01:00
irqflags.h
jump_label.h work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
kprobes.h
memory.h
mmu.h
mmu_context.h
page.h asm-generic updates for 6.13 2024-11-20 15:13:02 -08:00
pci.h
perf_event.h
pgalloc.h mm: call ctor/dtor for kernel PTEs 2025-05-11 17:48:21 -07:00
pgtable.h mm: pgtable: fix pte_swp_exclusive 2025-06-11 14:52:08 -07:00
probes.h
processor.h
ptrace.h csky: Fixup -Wmissing-prototypes warning 2023-08-10 23:06:32 -04:00
reg_ops.h
seccomp.h
sections.h csky: Fixup -Wmissing-prototypes warning 2023-08-10 23:06:32 -04:00
shmparam.h
smp.h
spinlock.h
spinlock_types.h
stackprotector.h
string.h
switch_to.h
syscall.h syscall.h: add syscall_set_arguments() 2025-05-11 17:48:15 -07:00
syscalls.h
tcm.h
thread_info.h
tlb.h
tlbflush.h
traps.h arch: add do_page_fault prototypes 2023-11-23 11:32:32 +01:00
uaccess.h
unistd.h csky: convert to generic syscall table 2024-07-10 14:23:38 +02:00
uprobes.h
vdso.h csky/vdso: Remove superfluous ifdeffery 2024-02-20 20:56:00 +01:00
vmalloc.h