]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crypto/isa-l/isa-l_crypto/sha512_mb/sha512_ctx_avx512.c
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / sha512_mb / sha512_ctx_avx512.c
index f99116eb17c2174a0ad282a58bf946dd486fb43d..5c07577161e6024bb73ffde286b3f0b866ac1c9b 100644 (file)
@@ -2,7 +2,7 @@
   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 "sha512_mb.h"
 #include "memcpy_inline.h"
+#include "endian_helper.h"
 
 #ifdef _MSC_VER
 # include <intrin.h>
@@ -38,7 +49,7 @@
 #ifdef HAVE_AS_KNOWS_AVX512
 
 static inline void hash_init_digest(SHA512_WORD_T * digest);
-static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint32_t total_len);
+static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len);
 static SHA512_HASH_CTX *sha512_ctx_mgr_resubmit(SHA512_HASH_CTX_MGR * mgr,
                                                SHA512_HASH_CTX * ctx);
 
@@ -222,9 +233,9 @@ static inline void hash_init_digest(SHA512_WORD_T * digest)
        memcpy_fixedlen(digest, hash_initial_digest, sizeof(hash_initial_digest));
 }
 
-static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint32_t total_len)
+static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len)
 {
-       uint32_t i = total_len & (SHA512_BLOCK_SIZE - 1);
+       uint32_t i = (uint32_t) (total_len & (SHA512_BLOCK_SIZE - 1));
 
        memclr_fixedlen(&padblock[i], SHA512_BLOCK_SIZE);
        padblock[i] = 0x80;
@@ -237,7 +248,7 @@ static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint32_
        *((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 >> SHA512_LOG2_BLOCK_SIZE;     // Number of extra blocks to hash
 }
@@ -257,3 +268,7 @@ struct slver sha512_ctx_mgr_flush_avx512_slver_0600016c;
 struct slver sha512_ctx_mgr_flush_avx512_slver = { 0x016c, 0x00, 0x06 };
 
 #endif // HAVE_AS_KNOWS_AVX512
+
+#if defined(__clang__)
+# pragma clang attribute pop
+#endif