freebsd-dev/lib/libc/string
Mateusz Guzik 710e45c4b8 Reimplement strlen
The previous code neglected to use primitives which can find the end
of the string without having to branch on every character.

While here augment the somewhat misleading commentary -- strlen as
implemented here leaves performance on the table, especially so for
userspace. Every arch should get a dedicated variant instead.

In the meantime this commit lessens the problem.

Tested with glibc test suite.

Naive test just calling strlen in a loop on Haswell (ops/s):

$(perl -e "print 'A' x 3"):
before:	211198039
after:	338626619

$(perl -e "print 'A' x 100"):
before:	83151997
after:	98285919
2021-01-29 23:48:26 +00:00
..
bcmp.3
bcmp.c
bcopy.3
bcopy.c
bstring.3
bzero.3
bzero.c
ffs.3
ffs.c
ffsl.c
ffsll.c
fls.c
flsl.c
flsll.c
index.3
Makefile.inc Implement strerror_l(). 2020-12-16 09:02:09 +00:00
memccpy.3
memccpy.c
memchr.3
memchr.c clang-format libc string functions imported from musl 2020-11-18 22:01:34 +00:00
memcmp.3
memcmp.c
memcpy.3
memcpy.c
memmem.3
memmem.c libc: fix undefined behavior from signed overflow in strstr and memmem 2020-11-19 00:03:15 +00:00
memmove.3
memmove.c
memrchr.c
memset_s.c
memset.3 memset.3: better fix previous typo 2020-02-08 21:17:48 +00:00
memset.c
stpcpy.c
stpncpy.c
strcasecmp.3
strcasecmp.c
strcasestr.c
strcat.3
strcat.c
strchr.3
strchr.c
strchrnul.c
strcmp.3
strcmp.c
strcoll.3
strcoll.c
strcpy.3 strcpy.3: Improve legibility and clarity 2018-06-06 20:09:21 +00:00
strcpy.c [PPC64] strcpy optimization 2020-01-15 19:46:01 +00:00
strcspn.c
strdup.3 strdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSD 2020-12-14 00:50:45 +00:00
strdup.c
strerror.3 strerror.3: Fix whitespace issue introduced in r368714 2020-12-18 22:10:17 +00:00
strerror.c Implement strerror_l(). 2020-12-16 09:02:09 +00:00
string.3
strlcat.c
strlcpy.3 libc manpages: various improvements from NetBSD 2020-06-14 05:59:30 +00:00
strlcpy.c
strlen.3
strlen.c Reimplement strlen 2021-01-29 23:48:26 +00:00
strmode.3
strmode.c
strncat.c
strncmp.c
strncpy.c [PPC64] strncpy optimization 2020-01-15 19:53:03 +00:00
strndup.c
strnlen.c
strnstr.c
strpbrk.3
strpbrk.c
strrchr.c
strsep.3 strsep.3: don't silently ignore errors 2018-05-28 18:29:15 +00:00
strsep.c
strsignal.c
strspn.3
strspn.c
strstr.3
strstr.c libc: fix undefined behavior from signed overflow in strstr and memmem 2020-11-19 00:03:15 +00:00
strtok.3 strtok(3): make it easier to find the RETURN VALUES section 2020-06-22 11:03:36 +00:00
strtok.c
strxfrm.3
strxfrm.c
swab.3
swab.c
Symbol.map Implement strerror_l(). 2020-12-16 09:02:09 +00:00
timingsafe_bcmp.3
timingsafe_bcmp.c
timingsafe_memcmp.c
wcpcpy.c
wcpncpy.c
wcscasecmp.c
wcscat.c
wcschr.c
wcscmp.c
wcscoll.3
wcscoll.c
wcscpy.c
wcscspn.c
wcsdup.c
wcslcat.c
wcslcpy.c
wcslen.c
wcsncasecmp.c
wcsncat.c
wcsncmp.c
wcsncpy.c
wcsnlen.c
wcspbrk.c
wcsrchr.c
wcsspn.c
wcsstr.c
wcstok.3
wcstok.c
wcswidth.3
wcswidth.c
wcsxfrm.3
wcsxfrm.c Fix a possible segfault in wcsxfrm(3) and wcsxfrm_l(3). 2019-08-07 20:13:43 +00:00
wmemchr.3
wmemchr.c
wmemcmp.c
wmemcpy.c
wmemmove.c
wmemset.c