mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-28 05:53:29 +01:00
MacOSX: use native OSX byte swapping routines used in hash functions to improve speed.
This commit is contained in:
parent
e40774f546
commit
e858d93a8e
@ -59,8 +59,15 @@
|
|||||||
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#elif defined(_MSC_VER) && _MSC_VER >= 1300
|
#elif defined(_MSC_VER) && _MSC_VER >= 1300
|
||||||
|
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
||||||
#define bswap_32(x) _byteswap_ulong(x)
|
#define bswap_32(x) _byteswap_ulong(x)
|
||||||
#define bswap_64(x) _byteswap_uint64(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
|
#else
|
||||||
#ifdef CRYPTOPP_FAST_ROTATE(32)
|
#ifdef CRYPTOPP_FAST_ROTATE(32)
|
||||||
#define bswap_32(x) (rotr32((x), 8U) & 0xff00ff00) | (rotl32((x), 8U) & 0x00ff00ff)
|
#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))
|
#define bswap_32(x) (rotl32((((x) & 0xFF00FF00) >> 8) | (((x) & 0x00FF00FF) << 8), 16U))
|
||||||
#endif
|
#endif
|
||||||
#ifndef TC_NO_COMPILER_INT64
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user