Clean up portable implementation of ROTL so that there is no
 undefined behaviour in shift and some commonly used compilers can
generate efficient code using rotate instructions.  This is tested on
x86_64, little-endian POWER and aarch64 with gcc-4.9 and current top
of trunk clang.  Both compilers generate native rotation instructions
for 32-bit inputs.  Since the portable implementation is now clean,
there is no need for the special code guarded by PEDANTIC.

---
 crypto/cast/cast_lcl.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/crypto/cast/cast_lcl.h b/crypto/cast/cast_lcl.h
index b0f0829..588da44 100644
--- a/crypto/cast/cast_lcl.h
+++ b/crypto/cast/cast_lcl.h
@@ -152,10 +152,8 @@

 #if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
 # define ROTL(a,n)     (_lrotl(a,n))
-#elif defined(PEDANTIC)
-# define ROTL(a,n)     ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31)))
 #else
-# define ROTL(a,n)     ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n))))
+# define ROTL(a,n)     ((((a)<<(n))|((a)>>(-(n)&31)))&0xffffffffL)
 #endif

 #define C_M    0x3fc
-- 
2.2.0.rc0.207.ga3a616c
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev

Reply via email to