Copyright(c) 2011-2016 Intel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
+ modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************/
+#if defined(__clang__)
+# pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
+#elif defined(__ICC)
+# pragma intel optimization_parameter target_arch=AVX2
+#elif defined(__ICL)
+# pragma [intel] optimization_parameter target_arch=AVX2
+#elif (__GNUC__ >= 5)
+# pragma GCC target("avx2")
+#endif
+
#include "sha1_mb.h"
#include "memcpy_inline.h"
+#include "endian_helper.h"
#ifdef _MSC_VER
# include <intrin.h>
#ifdef HAVE_AS_KNOWS_AVX512
static inline void hash_init_digest(SHA1_WORD_T * digest);
-static inline uint32_t hash_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2], uint32_t total_len);
+static inline uint32_t hash_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2], uint64_t total_len);
static SHA1_HASH_CTX *sha1_ctx_mgr_resubmit(SHA1_HASH_CTX_MGR * mgr, SHA1_HASH_CTX * ctx);
void sha1_ctx_mgr_init_avx512(SHA1_HASH_CTX_MGR * mgr)
memcpy_fixedlen(digest, hash_initial_digest, sizeof(hash_initial_digest));
}
-static inline uint32_t hash_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2], uint32_t total_len)
+static inline uint32_t hash_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2], uint64_t total_len)
{
- uint32_t i = total_len & (SHA1_BLOCK_SIZE - 1);
+ uint32_t i = (uint32_t) (total_len & (SHA1_BLOCK_SIZE - 1));
memclr_fixedlen(&padblock[i], SHA1_BLOCK_SIZE);
padblock[i] = 0x80;
*((uint64_t *) & padblock[i - 16]) = 0;
#endif
- *((uint64_t *) & padblock[i - 8]) = _byteswap_uint64((uint64_t) total_len << 3);
+ *((uint64_t *) & padblock[i - 8]) = to_be64((uint64_t) total_len << 3);
return i >> SHA1_LOG2_BLOCK_SIZE; // Number of extra blocks to hash
}
struct slver sha1_ctx_mgr_flush_avx512_slver = { 0x014c, 0x00, 0x06 };
#endif // HAVE_AS_KNOWS_AVX512
+
+#if defined(__clang__)
+# pragma clang attribute pop
+#endif