From f4c592dcdc0cd8211e72332f38d4183a0924366e Mon Sep 17 00:00:00 2001 From: rilysh Date: Tue, 10 Oct 2023 15:02:19 -0400 Subject: [PATCH] fix misleading msvc macro and two returns --- crc32.cpp | 7 +++---- keccak.cpp | 7 +++---- md5.cpp | 7 +++---- sha1.cpp | 7 +++---- sha256.cpp | 7 +++---- sha3.cpp | 8 +++----- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/crc32.cpp b/crc32.cpp index a1ad3c5..e0f5d73 100644 --- a/crc32.cpp +++ b/crc32.cpp @@ -322,15 +322,14 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap32(x); -#endif -#ifdef MSC_VER +#elif defined(_MSC_VER) return _byteswap_ulong(x); -#endif - +#else return (x >> 24) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) | (x << 24); +#endif } } diff --git a/keccak.cpp b/keccak.cpp index cba1cae..56d41d1 100644 --- a/keccak.cpp +++ b/keccak.cpp @@ -59,11 +59,9 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap64(x); -#endif -#ifdef _MSC_VER +#elif defined(_MSC_VER) return _byteswap_uint64(x); -#endif - +#else return (x >> 56) | ((x >> 40) & 0x000000000000FF00ULL) | ((x >> 24) & 0x0000000000FF0000ULL) | @@ -72,6 +70,7 @@ namespace ((x << 24) & 0x0000FF0000000000ULL) | ((x << 40) & 0x00FF000000000000ULL) | (x << 56); +#endif } diff --git a/md5.cpp b/md5.cpp index 2743319..456d87f 100644 --- a/md5.cpp +++ b/md5.cpp @@ -65,15 +65,14 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap32(x); -#endif -#ifdef MSC_VER +#elif defined(_MSC_VER) return _byteswap_ulong(x); -#endif - +#else return (x >> 24) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) | (x << 24); +#endif } #endif } diff --git a/sha1.cpp b/sha1.cpp index 8331e92..12bf8e4 100644 --- a/sha1.cpp +++ b/sha1.cpp @@ -61,15 +61,14 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap32(x); -#endif -#ifdef MSC_VER +#elif defined(_MSC_VER) return _byteswap_ulong(x); -#endif - +#else return (x >> 24) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) | (x << 24); +#endif } } diff --git a/sha256.cpp b/sha256.cpp index 8f0857d..063378f 100644 --- a/sha256.cpp +++ b/sha256.cpp @@ -65,15 +65,14 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap32(x); -#endif -#ifdef MSC_VER +#elif defined(_MSC_VER) return _byteswap_ulong(x); -#endif - +#else return (x >> 24) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) | (x << 24); +#endif } // mix functions for processBlock() diff --git a/sha3.cpp b/sha3.cpp index 2f6bc7b..f49dcc0 100644 --- a/sha3.cpp +++ b/sha3.cpp @@ -61,11 +61,9 @@ namespace { #if defined(__GNUC__) || defined(__clang__) return __builtin_bswap64(x); -#endif -#ifdef _MSC_VER +#elif defined(_MSC_VER) return _byteswap_uint64(x); -#endif - +#else return (x >> 56) | ((x >> 40) & 0x000000000000FF00ULL) | ((x >> 24) & 0x0000000000FF0000ULL) | @@ -74,9 +72,9 @@ namespace ((x << 24) & 0x0000FF0000000000ULL) | ((x << 40) & 0x00FF000000000000ULL) | (x << 56); +#endif } - /// return x % 5 for 0 <= x <= 9 unsigned int mod5(unsigned int x) {