HomeFreeBSD

swab.c(libc): use a simplified version of byte swapping

Description

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

Details

Provenance
rilysh <nightquick@proton.me>Authored on Apr 22 2024, 9:52 PM
impCommitted on Apr 23 2024, 5:01 AM
Parents
rGf578d0199761: ifconfig tunnelfib is implemented in wg(4)
Branches
Unknown
Tags
Unknown