diff --git a/CMake/Options.cmake b/CMake/Options.cmake index dd096d70c..70f937aa1 100644 --- a/CMake/Options.cmake +++ b/CMake/Options.cmake @@ -1,6 +1,8 @@ OPTION(ENABLE_COVERAGE "enable code coverage" OFF) OPTION(ENABLE_DEBUG "enable debug build" OFF) OPTION(ENABLE_SSE "enable SSE4.2 buildin function" ON) +message("##### ENABLE_SSE: ${ENABLE_SSE}") + OPTION(ENABLE_FRAME_POINTER "enable frame pointer on 64bit system with flag -fno-omit-frame-pointer, on 32bit system, it is always enabled" ON) OPTION(ENABLE_LIBCPP "using libc++ instead of libstdc++, only valid for clang compiler" OFF) OPTION(ENABLE_BOOST "using boost instead of native compiler c++0x support" OFF) diff --git a/src/common/HWCrc32c.cpp b/src/common/HWCrc32c.cpp index 1c4d92cef..7b4f3e178 100644 --- a/src/common/HWCrc32c.cpp +++ b/src/common/HWCrc32c.cpp @@ -34,7 +34,11 @@ #include #endif -#if ((defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64))) +#if defined(__loongarch64) +#include +#endif + +#if ((defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64) || defined(__loongarch64))) #if !defined(__SSE4_2__) namespace Hdfs { @@ -42,23 +46,39 @@ namespace Internal { #if defined(__LP64__) static inline uint64_t _mm_crc32_u64(uint64_t crc, uint64_t value) { +#if defined(__loongarch64) + crc = __crcc_w_d_w(value,crc); +#else asm("crc32q %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value)); +#endif return crc; } #endif static inline uint32_t _mm_crc32_u16(uint32_t crc, uint16_t value) { +#if defined(__loongarch64) + crc = __crcc_w_h_w(value,crc); +#else asm("crc32w %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value)); +#endif return crc; } static inline uint32_t _mm_crc32_u32(uint32_t crc, uint64_t value) { +#if defined(__loongarch64) + crc = __crcc_w_w_w(value,crc); +#else asm("crc32l %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value)); +#endif return crc; } static inline uint32_t _mm_crc32_u8(uint32_t crc, uint8_t value) { +#if defined(__loongarch64) + crc = __crcc_w_b_w(value,crc); +#else asm("crc32b %[value], %[crc]\n" : [crc] "+r"(crc) : [value] "rm"(value)); +#endif return crc; } @@ -86,13 +106,14 @@ bool HWCrc32c::available() { */ __get_cpuid(1, &eax, &ebx, &ecx, &edx); return (ecx & (1 << 20)) != 0; -#elif ((defined(__arm__) || defined(__aarch64__))) +#elif ((defined(__arm__) || defined(__aarch64__) || defined(__loongarch64))) return true; #else return false; #endif } +#if !(((defined(__PPC64__) || defined(__powerpc64__)) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || (defined(__s390x__))) void HWCrc32c::update(const void * b, int len) { const char * p = static_cast(b); #if defined(__LP64__) @@ -164,5 +185,6 @@ void HWCrc32c::updateInt64(const char * b, int len) { } } +#endif } -} +} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 605db2eea..727b1c554 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -20,5 +20,10 @@ "name": "vcpkg-cmake", "host": true } - ] + ], + "features": { + "sse": { + "description": "enable sse" + } + } }