Author: mturk
Date: Tue Aug 11 12:22:52 2009
New Revision: 803083
URL: http://svn.apache.org/viewvc?rev=803083&view=rev
Log:
Use assembler rotate function for MSVC 2003 and up
Modified:
commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c?rev=803083&r1=803082&r2=803083&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c Tue Aug 11
12:22:52 2009
@@ -112,10 +112,23 @@
*/
/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */
#define R(b,x) ((x) >> (b))
+
+#if defined(_MSC_VER)
+/* 32-bit Rotate-right (used in SHA-256): */
+#define S32(b,x) _rotr((x), (b))
+#if _MSC_VER >= 1300
+/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
+#define S64(b,x) _rotr64((x), (b))
+#else
+/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
+#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
+#endif
+#else
/* 32-bit Rotate-right (used in SHA-256): */
#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b))))
/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
+#endif
/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */
#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))