-
-
Save jfalcou/20a51bf62f0cef11deae0e471fe7902a to your computer and use it in GitHub Desktop.
rol implementation that trigger use of x86 ROL intrinsic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
std::uint64_t rotl32c (std::uint64_t x, std::uint64_t n) | |
{ | |
return (x<<n) | (x>>(-n&63)); | |
} | |
std::uint32_t rotl32c (std::uint32_t x, std::uint32_t n) | |
{ | |
return (x<<n) | (x>>(-n&31)); | |
} | |
std::uint16_t rotl32c (std::uint16_t x, std::uint16_t n) | |
{ | |
return (x<<n) | (x>>(-n&15)); | |
} | |
std::uint8_t rotl32c (std::uint8_t x, std::uint8_t n) | |
{ | |
return (x<<n) | (x>>(-n&7)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment