This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldiag: A deprecation is now fatal
[perl5.git] / sbox32_hash.h
index 748256c..766102f 100644 (file)
 
 #ifndef PERL_SEEN_HV_FUNC_H
 #if !defined(U32) 
-    #include <stdint.h>
-    #define U32 uint32_t
+#include <stdint.h>
+#define U32 uint32_t
 #endif
 
 #if !defined(U8)
-    #define U8 unsigned char
+#define U8 unsigned char
 #endif
 
 #if !defined(U16)
-    #define U16 uint16_t
+#define U16 uint16_t
 #endif
 
 #ifndef STRLEN
 #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
 #endif
 
 #define _SBOX32_CASE(len,hash,state,key) \
+    /* FALLTHROUGH */ \
     case len: hash ^= state[ 1 + ( 256 * ( len - 1 ) ) + key[ len - 1 ] ];
 
 
@@ -1773,5 +1780,4 @@ SBOX32_STATIC_INLINE U32 sbox32_hash128(
     return sbox32_hash_with_state((U8*)state,key,key_len);
 }
 
-
 #endif