From 28ac48d112cb7a8c63963adcd28b2587d96e6b94 Mon Sep 17 00:00:00 2001 From: SeungHwan Hur Date: Thu, 1 Aug 2024 20:55:04 +0900 Subject: [PATCH] help MSVC optimize ROL/ROR functions (#1392) --- src/libsodium/include/sodium/private/common.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libsodium/include/sodium/private/common.h b/src/libsodium/include/sodium/private/common.h index 63f0d2b2..7ac70d23 100644 --- a/src/libsodium/include/sodium/private/common.h +++ b/src/libsodium/include/sodium/private/common.h @@ -30,6 +30,15 @@ typedef unsigned uint128_t __attribute__((mode(TI))); # endif #endif +# if defined(_MSC_VER) + +#define ROTL32(X, B) _rotl((X), (B)) +#define ROTL64(X, B) _rotl64((X), (B)) +#define ROTR32(X, B) _rotr((X), (B)) +#define ROTR64(X, B) _rotr64((X), (B)) + +#else + #define ROTL32(X, B) rotl32((X), (B)) static inline uint32_t rotl32(const uint32_t x, const int b) @@ -58,6 +67,8 @@ rotr64(const uint64_t x, const int b) return (x >> b) | (x << (64 - b)); } +#endif + #define LOAD64_LE(SRC) load64_le(SRC) static inline uint64_t load64_le(const uint8_t src[8])