Skip to content

Commit

Permalink
update libhdfs3
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Sep 13, 2024
1 parent f91dff1 commit 5ad4320
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMake/Options.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
28 changes: 25 additions & 3 deletions src/common/HWCrc32c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,51 @@
#include <cpuid.h>
#endif

#if ((defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64)))
#if defined(__loongarch64)
#include <larchintrin.h>
#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 {
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;
}

Expand Down Expand Up @@ -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<const char *>(b);
#if defined(__LP64__)
Expand Down Expand Up @@ -164,5 +185,6 @@ void HWCrc32c::updateInt64(const char * b, int len) {
}
}

#endif
}
}
}
7 changes: 6 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"name": "vcpkg-cmake",
"host": true
}
]
],
"features": {
"sse": {
"description": "enable sse"
}
}
}

0 comments on commit 5ad4320

Please sign in to comment.