From 5e141e336c3a2cb8921edcd7af6f14a29ff63942 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Wed, 27 Dec 2023 06:51:29 -0600 Subject: add cheap SHA1 implementation --- src/endian.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/endian.c (limited to 'src/endian.c') diff --git a/src/endian.c b/src/endian.c new file mode 100644 index 0000000..0229c57 --- /dev/null +++ b/src/endian.c @@ -0,0 +1,28 @@ +#include "endian.h" + +#include + +uint64_t l2__bswap_64_int(uint64_t in) +{ + return (in << 56) + | ((in & UINT64_C(0x000000000000FF00)) << 40) + | ((in & UINT64_C(0x0000000000FF0000)) << 24) + | ((in & UINT64_C(0x00000000FF000000)) << 8) + | ((in & UINT64_C(0x000000FF00000000)) >> 8) + | ((in & UINT64_C(0x0000FF0000000000)) >> 24) + | ((in & UINT64_C(0x00FF000000000000)) >> 40) + | (in >> 56); +} + +uint32_t l2__bswap_32_int(uint32_t in) +{ + return (in << 24) + | ((in & UINT32_C(0x0000FF00)) << 8) + | ((in & UINT32_C(0x00FF0000)) >> 8) + | (in >> 24); +} + +uint16_t l2__bswap_16_int(uint16_t in) +{ + return (in >> 8) | (in << 8); +} -- cgit v1.2.3-70-g09d2