summaryrefslogtreecommitdiff
path: root/sbox32_hash.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2017-10-12 17:57:21 +0200
committerYves Orton <demerphq@gmail.com>2017-10-12 17:57:21 +0200
commitd939098ccc7209faf586b0a2cca8b202f4c297f1 (patch)
tree000379ada7d3ad3a979540c6d4a8608e1cde4461 /sbox32_hash.h
parenta68a847ef5e609337bd3f538810884d3b918bfb8 (diff)
downloadperl-d939098ccc7209faf586b0a2cca8b202f4c297f1.tar.gz
hopefully better macros for building on x86
Diffstat (limited to 'sbox32_hash.h')
-rw-r--r--sbox32_hash.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/sbox32_hash.h b/sbox32_hash.h
index 748256c71c..66f27accbc 100644
--- a/sbox32_hash.h
+++ b/sbox32_hash.h
@@ -59,11 +59,17 @@
#define STMT_END while(0)
#endif
-#ifndef U8TO32_LE
-#define U8TO32_LE(ptr) (*((const U32 *)(ptr)))
+/* Find best way to ROTL32/ROTL64 */
+#ifndef ROTL32
+#if defined(_MSC_VER)
+ #include <stdlib.h> /* Microsoft put _rotl declaration in here */
+ #define ROTL32(x,r) _rotl(x,r)
+ #define ROTR32(x,r) _rotr(x,r)
+#else
+ /* gcc recognises this code and generates a rotate instruction for CPUs with one */
+ #define ROTL32(x,r) (((U32)(x) << (r)) | ((U32)(x) >> (32 - (r))))
+ #define ROTR32(x,r) (((U32)(x) << (32 - (r))) | ((U32)(x) >> (r)))
#endif
-#ifndef U8TO16_LE
-#define U8TO16_LE(ptr) (*((const U16 *)(ptr)))
#endif
#ifndef SBOX32_MAX_LEN