Skip to content

Commit

Permalink
help MSVC optimize ROL/ROR functions (#1392)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1net4il-shiftup authored Aug 1, 2024
1 parent 563ec3d commit e1861bb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libsodium/include/sodium/private/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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)
Expand Down Expand Up @@ -60,6 +69,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])
Expand Down

0 comments on commit e1861bb

Please sign in to comment.