Re: [PATCH] smaller strlen()
From: Joe Perches
Date: Fri Aug 26 2016 - 18:23:28 EST
On Fri, 2016-08-26 at 23:01 +0300, Alexey Dobriyan wrote:
> gcc prefers "*s++" style code for some reason, doesn't unroll loop
> condition check once. Kernel strings are small but they aren't of 0
> length, so that additional branch was almost never taken.
Hey Alexey.
Is this gcc version specific?
And I'm confused why there isn't an asm __HAVE_ARCH_STRLEN
version x86_64 strlen like x86_32 or if __builtin_strlen()
is or isn't used. Maybe Andi Kleen knows/remembers (cc'd).
> $ ./scripts/bloat-o-meter ../vmlinux-000 ../obj/vmlinux
> strlen 30 26 -4
> strlcpy 71 64 -7
> strlcat 120 99 -21
>
> strlcpy() and strlcat() are collateral damage :^)