diff options
author | lloyd <[email protected]> | 2009-11-10 23:38:12 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-10 23:38:12 +0000 |
commit | f2de721b8e0f57ab64a317ee350535829b71b94a (patch) | |
tree | 00fbcd5e1a853f61b0af92625334e358e2c9c887 /src/utils | |
parent | 7a3ee74d35ebef79b0ae38f798a85eaf7f452abc (diff) |
Use memcpy for bulk loads if algorithm endianness matches CPU endianess.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/loadstor.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/loadstor.h b/src/utils/loadstor.h index 489a789f4..b15cafd2c 100644 --- a/src/utils/loadstor.h +++ b/src/utils/loadstor.h @@ -13,6 +13,7 @@ #include <botan/bswap.h> #include <botan/rotate.h> #include <botan/prefetch.h> +#include <cstring> #if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK @@ -203,6 +204,9 @@ inline void load_le(T out[], const byte in[], u32bit count) { +#if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN) + std::memcpy(out, in, sizeof(T)*count); +#else const u32bit blocks = count - (count % 4); const u32bit left = count - blocks; @@ -219,6 +223,7 @@ inline void load_le(T out[], for(u32bit i = 0; i != left; ++i) out[i] = load_le<T>(in, i); +#endif } template<typename T> @@ -258,6 +263,9 @@ inline void load_be(T out[], const byte in[], u32bit count) { +#if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN) + std::memcpy(out, in, sizeof(T)*count); +#else const u32bit blocks = count - (count % 4); const u32bit left = count - blocks; @@ -274,6 +282,7 @@ inline void load_be(T out[], for(u32bit i = 0; i != left; ++i) out[i] = load_be<T>(in, i); +#endif } /* |