VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-01-11 01:03:02 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-01-11 01:04:54 +0100
commite858d93a8ee1d4786a25f3d3b124c5c477f05d5d (patch)
tree9097e8bdfdec70920f85f343c61e39b0ceff6f8a
parente40774f54683ba24ffed63aa14bebc8ab42ed087 (diff)
downloadVeraCrypt-e858d93a8ee1d4786a25f3d3b124c5c477f05d5d.tar.gz
VeraCrypt-e858d93a8ee1d4786a25f3d3b124c5c477f05d5d.zip
MacOSX: use native OSX byte swapping routines used in hash functions to improve speed.
-rw-r--r--src/Crypto/misc.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Crypto/misc.h b/src/Crypto/misc.h
index 78044491..30346afc 100644
--- a/src/Crypto/misc.h
+++ b/src/Crypto/misc.h
@@ -33,8 +33,8 @@
#define CRYPTOPP_FAST_ROTATE(x) 0
#endif
-#if defined( _MSC_VER ) && ( _MSC_VER > 800 )
-#pragma intrinsic(memcpy,memset)
+#if defined( _MSC_VER ) && ( _MSC_VER > 800 )
+#pragma intrinsic(memcpy,memset)
#endif
#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
@@ -59,8 +59,15 @@
#define CRYPTOPP_BYTESWAP_AVAILABLE
#include <byteswap.h>
#elif defined(_MSC_VER) && _MSC_VER >= 1300
+#define CRYPTOPP_BYTESWAP_AVAILABLE
#define bswap_32(x) _byteswap_ulong(x)
#define bswap_64(x) _byteswap_uint64(x)
+#elif defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+#define CRYPTOPP_BYTESWAP_AVAILABLE
+#define bswap_16 OSSwapInt16
+#define bswap_32 OSSwapInt32
+#define bswap_64 OSSwapInt64
#else
#ifdef CRYPTOPP_FAST_ROTATE(32)
#define bswap_32(x) (rotr32((x), 8U) & 0xff00ff00) | (rotl32((x), 8U) & 0x00ff00ff)
@@ -68,7 +75,7 @@
#define bswap_32(x) (rotl32((((x) & 0xFF00FF00) >> 8) | (((x) & 0x00FF00FF) << 8), 16U))
#endif
#ifndef TC_NO_COMPILER_INT64
-#define bswap_64(x) rotl64(((((((value & LL(0xFF00FF00FF00FF00)) >> 8) | ((value & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0xFFFF0000FFFF0000)) >> 16) | (((((value & LL(0xFF00FF00FF00FF00)) >> 8) | ((value & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0x0000FFFF0000FFFF)) << 16)), 32U)
+#define bswap_64(x) rotl64(((((((x & LL(0xFF00FF00FF00FF00)) >> 8) | ((x & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0xFFFF0000FFFF0000)) >> 16) | (((((x & LL(0xFF00FF00FF00FF00)) >> 8) | ((x & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0x0000FFFF0000FFFF)) << 16)), 32U)
#endif
#endif