From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:24:58 +0000 (-0500) Subject: fundamental: prefer byte swap builtins over byte swapping manually X-Git-Tag: v256-rc1~1338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb924b9b6a963d0bad5725cae9016fb513383531;p=thirdparty%2Fsystemd.git fundamental: prefer byte swap builtins over byte swapping manually This builtin reduces complexity and GCC/Clang have supported these builtins for a long time. --- diff --git a/src/fundamental/sha256.c b/src/fundamental/sha256.c index 4389e9e37c5..4447ad8a660 100644 --- a/src/fundamental/sha256.c +++ b/src/fundamental/sha256.c @@ -34,16 +34,9 @@ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) + __builtin_bswap32(n) # define SWAP64(n) \ - (((n) << 56) \ - | (((n) & 0xff00) << 40) \ - | (((n) & 0xff0000) << 24) \ - | (((n) & 0xff000000) << 8) \ - | (((n) >> 8) & 0xff000000) \ - | (((n) >> 24) & 0xff0000) \ - | (((n) >> 40) & 0xff00) \ - | ((n) >> 56)) + __builtin_bswap64(n) #else # define SWAP(n) (n) # define SWAP64(n) (n)