From 5a843719b1f145edc7823c98938daf8cd83af209 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 23 Feb 2017 09:35:28 +0100 Subject: [PATCH] Use inlined functions instead of macros --- src/libsodium/include/sodium/private/common.h | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/libsodium/include/sodium/private/common.h b/src/libsodium/include/sodium/private/common.h index d3ab8dd6..3ee9dd85 100644 --- a/src/libsodium/include/sodium/private/common.h +++ b/src/libsodium/include/sodium/private/common.h @@ -7,10 +7,33 @@ #define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1]) -#define ROTL32(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b)))) -#define ROTL64(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) -#define ROTR32(x, b) (uint32_t)(((x) >> (b)) | ((x) << (32 - (b)))) -#define ROTR64(x, b) (uint64_t)(((x) >> (b)) | ((x) << (64 - (b)))) +#define ROTL32(X, B) rotl32((X), (B)) +static inline uint32_t +rotl32(const uint32_t x, const int b) +{ + return (x << b) | (x >> (32 - b)); +} + +#define ROTL64(X, B) rotl64((X), (B)) +static inline uint64_t +rotl64(const uint64_t x, const int b) +{ + return (x << b) | (x >> (64 - b)); +} + +#define ROTR32(X, B) rotr32((X), (B)) +static inline uint32_t +rotr32(const uint32_t x, const int b) +{ + return (x >> b) | (x << (32 - b)); +} + +#define ROTR64(X, B) rotr64((X), (B)) +static inline uint64_t +rotr64(const uint64_t x, const int b) +{ + return (x >> b) | (x << (64 - b)); +} #define LOAD64_LE(SRC) load64_le(SRC) static inline uint64_t