This is an automated email from the ASF dual-hosted git repository.

yangzhg pushed a commit to branch libhdfs3
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git

commit 0eaffe6ae30f88a603cf2e6db947be399f4dc459
Author: yangzhg <[email protected]>
AuthorDate: Mon Jun 6 21:18:04 2022 +0800

    fix arm support
---
 src/common/HWCrc32c.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/src/common/HWCrc32c.cpp b/src/common/HWCrc32c.cpp
index 32d8005..1152745 100644
--- a/src/common/HWCrc32c.cpp
+++ b/src/common/HWCrc32c.cpp
@@ -23,7 +23,50 @@
 #include <cstdlib>
 
 #include "HWCrc32c.h"
+
+#if ((defined(__X86__) || defined(__i386__) || defined(i386) || 
defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64)))
+#include <cpuid.h>
+#endif
+
+#if ((defined(__X86__) || defined(__i386__) || defined(i386) || 
defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64)))
+#if !defined(__SSE4_2__)
+
+namespace Hdfs {
+namespace Internal {
+
+#if defined(__LP64__)
+static inline uint64_t _mm_crc32_u64(uint64_t crc, uint64_t value) {
+    asm("crc32q %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value));
+    return crc;
+}
+#endif
+
+static inline uint32_t _mm_crc32_u16(uint32_t crc, uint16_t value) {
+    asm("crc32w %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value));
+    return crc;
+}
+
+static inline uint32_t _mm_crc32_u32(uint32_t crc, uint64_t value) {
+    asm("crc32l %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value));
+    return crc;
+}
+
+static inline uint32_t _mm_crc32_u8(uint32_t crc, uint8_t value) {
+    asm("crc32b %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value));
+    return crc;
+}
+
+}
+}
+
+#else
+
+#include <nmmintrin.h>
+
+#endif
+#elseif ((defined(__arm__) || defined(__aarch64__))) 
 #include "sse2neon.h"
+#endif
 
 namespace Hdfs {
 namespace Internal {
@@ -37,7 +80,7 @@ bool HWCrc32c::available() {
      */
     __get_cpuid(1, &eax, &ebx, &ecx, &edx);
     return (ecx & (1 << 20)) != 0;
-#elseif ((defined(__arm__) || defined(__aarch64__))) {
+#elseif ((defined(__arm__) || defined(__aarch64__)))
     return true;
 #else
     return false;
@@ -116,4 +159,4 @@ void HWCrc32c::updateInt64(const char * b, int len) {
 }
 
 }
-}
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to