mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-08-15 00:23:14 +00:00
Fix undefined behavior in rotr/rotl (#86)
This commit is contained in:
parent
1f62d787ad
commit
6ea6cceb63
2 changed files with 8 additions and 8 deletions
|
@ -51,10 +51,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#include <stdlib.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);
|
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);
|
return _rotr64(x, c);
|
||||||
}
|
}
|
||||||
#define HAVE_ROTL
|
#define HAVE_ROTL
|
||||||
|
@ -89,15 +89,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_ROTR
|
#ifndef HAVE_ROTR
|
||||||
uint64_t rotr(uint64_t a, int b) {
|
uint64_t rotr(uint64_t a, unsigned int b) {
|
||||||
return (a >> b) | (a << (64 - b));
|
return (a >> b) | (a << (-b & 63));
|
||||||
}
|
}
|
||||||
#define HAVE_ROTR
|
#define HAVE_ROTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_ROTL
|
#ifndef HAVE_ROTL
|
||||||
uint64_t rotl(uint64_t a, int b) {
|
uint64_t rotl(uint64_t a, unsigned int b) {
|
||||||
return (a << b) | (a >> (64 - b));
|
return (a << b) | (a >> (-b & 63));
|
||||||
}
|
}
|
||||||
#define HAVE_ROTL
|
#define HAVE_ROTL
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -594,5 +594,5 @@ void rx_set_rounding_mode(uint32_t mode);
|
||||||
double loadDoublePortable(const void* addr);
|
double loadDoublePortable(const void* addr);
|
||||||
uint64_t mulh(uint64_t, uint64_t);
|
uint64_t mulh(uint64_t, uint64_t);
|
||||||
int64_t smulh(int64_t, int64_t);
|
int64_t smulh(int64_t, int64_t);
|
||||||
uint64_t rotl(uint64_t, int);
|
uint64_t rotl(uint64_t, unsigned int);
|
||||||
uint64_t rotr(uint64_t, int);
|
uint64_t rotr(uint64_t, unsigned int);
|
||||||
|
|
Loading…
Reference in a new issue