mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-12-21 23:38:54 +00:00
Fix undefined behavior in rotr/rotl (#86)
This commit is contained in:
parent
1f62d787ad
commit
6ea6cceb63
@ -51,10 +51,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <intrin.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint64_t rotl(uint64_t x, int c) {
|
||||
uint64_t rotl(uint64_t x, unsigned int c) {
|
||||
return _rotl64(x, c);
|
||||
}
|
||||
uint64_t rotr(uint64_t x , int c) {
|
||||
uint64_t rotr(uint64_t x, unsigned int c) {
|
||||
return _rotr64(x, c);
|
||||
}
|
||||
#define HAVE_ROTL
|
||||
@ -89,15 +89,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ROTR
|
||||
uint64_t rotr(uint64_t a, int b) {
|
||||
return (a >> b) | (a << (64 - b));
|
||||
uint64_t rotr(uint64_t a, unsigned int b) {
|
||||
return (a >> b) | (a << (-b & 63));
|
||||
}
|
||||
#define HAVE_ROTR
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ROTL
|
||||
uint64_t rotl(uint64_t a, int b) {
|
||||
return (a << b) | (a >> (64 - b));
|
||||
uint64_t rotl(uint64_t a, unsigned int b) {
|
||||
return (a << b) | (a >> (-b & 63));
|
||||
}
|
||||
#define HAVE_ROTL
|
||||
#endif
|
||||
|
@ -594,5 +594,5 @@ void rx_set_rounding_mode(uint32_t mode);
|
||||
double loadDoublePortable(const void* addr);
|
||||
uint64_t mulh(uint64_t, uint64_t);
|
||||
int64_t smulh(int64_t, int64_t);
|
||||
uint64_t rotl(uint64_t, int);
|
||||
uint64_t rotr(uint64_t, int);
|
||||
uint64_t rotl(uint64_t, unsigned int);
|
||||
uint64_t rotr(uint64_t, unsigned int);
|
||||
|
Loading…
Reference in New Issue
Block a user