freebsd-src/lib/libc/string
rilysh bac2eea13a swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent
bytes. Previous version of swab() used an arbitrary unrolling, which was
relevant back in the day but unnecessary for modern compilers, as if the
input size is known at compile time, they can do it automatically.

This version of swab() is inspired by musl.
A similar version can be found at: https://github.com/openbsd/src/blob/master/lib/libc/string/swab.c

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1086
2024-04-22 23:01:54 -06:00
..
bcmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcopy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcopy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bstring.3 lib/libc/string: document restrict qualification of memccpy() arguments 2023-12-25 14:59:50 +01:00
bzero.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bzero.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
ffs.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
ffs.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
ffsl.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
ffsll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
fls.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
flsl.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
flsll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
index.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
Makefile.inc lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memccpy.3 lib/libc/string: document restrict qualification of memccpy() arguments 2023-12-25 14:59:50 +01:00
memccpy.c lib/libc/string: document restrict qualification of memccpy() arguments 2023-12-25 14:59:50 +01:00
memchr.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memcmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memcpy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memcpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memmem.3 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
memmem.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memmove.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memmove.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
mempcpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memrchr.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
memset.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memset.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memset_s.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
stpcpy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
stpncpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcasecmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcasecmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcasestr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcat.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcat.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strchr.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strchrnul.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcoll.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcoll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcpy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcpy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcspn.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strdup.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strdup.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strerror.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strerror.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
string.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strlcat.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strlcpy.3 strlcpy/strlcat: Remove references to snprintf 2023-10-27 10:13:50 -06:00
strlcpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strlen.3 strnlen(3): add HISTORY 2024-03-15 14:52:47 -07:00
strlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strmode.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strmode.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strncat.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strncmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strncpy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strndup.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strnlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strnstr.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strpbrk.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strpbrk.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strrchr.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsep.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsep.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsignal.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strspn.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strspn.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strstr.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strstr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strtok.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strtok.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strverscmp.3 libc: fix history for strverscmp(3) and versionsort(3) 2023-08-31 14:52:31 +03:00
strverscmp.c libc: Add strverscmp(3) and versionsort(3) 2022-08-25 03:29:03 +03:00
strxfrm.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strxfrm.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
swab.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
swab.c swab.c(libc): use a simplified version of byte swapping 2024-04-22 23:01:54 -06:00
Symbol.map libc: Remove empty comments in Symbol.map 2023-11-15 17:51:03 +00:00
timingsafe_bcmp.3 timingsafe_bcmp(3) was MFC'ed to 11.1 2024-01-05 20:54:13 -08:00
timingsafe_bcmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
timingsafe_memcmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcpcpy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
wcpncpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscasecmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscat.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcschr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscmp.c sccs: Manual changes 2023-11-26 22:23:58 -07:00
wcscoll.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
wcscoll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscpy.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcscspn.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsdup.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcslcat.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcslcpy.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcslen.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsncasecmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsncat.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsncmp.c sccs: Manual changes 2023-11-26 22:23:58 -07:00
wcsncpy.c lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
wcsnlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcspbrk.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsrchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsspn.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsstr.c lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
wcstok.3 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
wcstok.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcswidth.3 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
wcswidth.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsxfrm.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
wcsxfrm.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wmemchr.3 wmemchr(3): fix prototypes for wcpcpy() and wcpncpy() 2024-03-21 10:40:08 +02:00
wmemchr.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmemcmp.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmemcpy.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmemmove.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmempcpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wmemset.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00