github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/rocksdb/arm64_crc.patch (about) 1 diff --git a/util/crc32c.cc b/util/crc32c.cc 2 index 959658099..74ce80b36 100644 3 --- a/util/crc32c.cc 4 +++ b/util/crc32c.cc 5 @@ -41,7 +41,7 @@ 6 7 #endif 8 9 -#if defined(__linux__) && defined(HAVE_ARM64_CRC) 10 +#if defined(HAVE_ARM64_CRC) 11 bool pmull_runtime_flag = false; 12 #endif 13 14 @@ -346,6 +346,7 @@ static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) { 15 table0_[c >> 24]; 16 } 17 18 +#if defined HAVE_SSE42 && defined NO_THREEWAY_CRC32C 19 static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) { 20 #ifndef HAVE_SSE42 21 Slow_CRC32(l, p); 22 @@ -359,6 +360,7 @@ static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) { 23 *p += 4; 24 #endif 25 } 26 +#endif 27 28 template<void (*CRC32)(uint64_t*, uint8_t const**)> 29 uint32_t ExtendImpl(uint32_t crc, const char* buf, size_t size) { 30 @@ -474,7 +476,7 @@ static bool isAltiVec() { 31 } 32 #endif 33 34 -#if defined(__linux__) && defined(HAVE_ARM64_CRC) 35 +#if defined(HAVE_ARM64_CRC) 36 uint32_t ExtendARMImpl(uint32_t crc, const char *buf, size_t size) { 37 return crc32c_arm64(crc, (const unsigned char *)buf, size); 38 } 39 @@ -494,7 +496,7 @@ std::string IsFastCrc32Supported() { 40 has_fast_crc = false; 41 arch = "PPC"; 42 #endif 43 -#elif defined(__linux__) && defined(HAVE_ARM64_CRC) 44 +#elif defined(HAVE_ARM64_CRC) 45 if (crc32c_runtime_check()) { 46 has_fast_crc = true; 47 arch = "Arm64"; 48 @@ -1227,7 +1229,7 @@ uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) { 49 static inline Function Choose_Extend() { 50 #ifdef HAVE_POWER8 51 return isAltiVec() ? ExtendPPCImpl : ExtendImpl<Slow_CRC32>; 52 -#elif defined(__linux__) && defined(HAVE_ARM64_CRC) 53 +#elif defined(HAVE_ARM64_CRC) 54 if(crc32c_runtime_check()) { 55 pmull_runtime_flag = crc32c_pmull_runtime_check(); 56 return ExtendARMImpl; 57 diff --git a/util/crc32c_arm64.cc b/util/crc32c_arm64.cc 58 index 566810f4b..e26897499 100644 59 --- a/util/crc32c_arm64.cc 60 +++ b/util/crc32c_arm64.cc 61 @@ -5,9 +5,11 @@ 62 63 #include "util/crc32c_arm64.h" 64 65 -#if defined(__linux__) && defined(HAVE_ARM64_CRC) 66 +#if defined(HAVE_ARM64_CRC) 67 68 +#if defined(__linux__) 69 #include <asm/hwcap.h> 70 +#endif 71 #ifdef ROCKSDB_AUXV_GETAUXVAL_PRESENT 72 #include <sys/auxv.h> 73 #endif 74 @@ -66,7 +68,7 @@ __attribute__((__no_sanitize_undefined__)) 75 #endif 76 #endif 77 uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, 78 - unsigned len) { 79 + size_t len) { 80 const uint8_t *buf8; 81 const uint64_t *buf64 = (uint64_t *)data; 82 int length = (int)len; 83 diff --git a/util/crc32c_arm64.h b/util/crc32c_arm64.h 84 index a12354683..168cc81c2 100644 85 --- a/util/crc32c_arm64.h 86 +++ b/util/crc32c_arm64.h 87 @@ -7,6 +7,7 @@ 88 #define UTIL_CRC32C_ARM64_H 89 90 #include <cinttypes> 91 +#include <cstddef> 92 93 #if defined(__aarch64__) || defined(__AARCH64__) 94 95 @@ -33,7 +34,7 @@ 96 PREF4X64L1(buffer, (PREF_OFFSET), 8) \ 97 PREF4X64L1(buffer, (PREF_OFFSET), 12) 98 99 -extern uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, unsigned len); 100 +extern uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len); 101 extern uint32_t crc32c_runtime_check(void); 102 extern bool crc32c_pmull_runtime_check(void); 103