jimmystewpot commented on code in PR #3754:
URL: https://github.com/apache/brpc/pull/3754#discussion_r4725866965


##########
src/butil/crc32c.cc:
##########
@@ -290,12 +330,20 @@ static const uint32_t table3_[256] = {
 // Lower-level versions of Get... that read directly from a character buffer
 // without any bounds checking.
 
+#if defined(BUTIL_ARM64_CRC32_ENABLED)
+static inline uint16_t DecodeFixed16(const char* ptr) {
+  uint16_t result;
+  memcpy(&result, ptr, sizeof(result));
+  return result;
+}
+#endif
+
 static inline uint32_t DecodeFixed32(const char* ptr) {
-#if defined(ARCH_CPU_LITTLE_ENDIAN) && ARCH_CPU_LITTLE_ENDIAN
-    // Load the raw bytes
-    uint32_t result;
-    memcpy(&result, ptr, sizeof(result));  // gcc optimizes this to a plain 
load
-    return result;
+#if BUTIL_CRC32C_LITTLE_ENDIAN
+  // Load the raw bytes
+  uint32_t result;
+  memcpy(&result, ptr, sizeof(result));  // gcc optimizes this to a plain load
+  return result;
 #else
     return ((static_cast<uint32_t>(static_cast<unsigned char>(ptr[0])))

Review Comment:
   Fixed in `522e865a` and `f853d120`.
   
   Restored `DecodeFixed32` and `DecodeFixed64` verbatim to `master` and 
removed `BUTIL_CRC32C_LITTLE_ENDIAN`, while keeping `BUTIL_ARM64_CRC32_ENABLED` 
positively gated on little-endian ARM64 (`__BYTE_ORDER__ == 
__ORDER_LITTLE_ENDIAN__` and no big-endian macros). Big-endian ARM64 now 
executes the unmodified `master` software path regardless of CPU `FEAT_CRC32` 
support, preserving rolling-upgrade checksum compatibility under 
`CHECKSUM_TYPE_CRC32C` so any big-endian format correction can be handled 
separately.
   
   In `test/crc32c_unittest.cc`, added an `IsBigEndianArm64()` `GTEST_SKIP()` 
guard to the five new RFC 3720 reference tests (`ChunkIndependence`, 
`UnalignedAndAllTailLengths`, `LargeBuffersAndSeeds`, 
`TightBoundsAndAllArm64Paths`, and `GuardPageAndWideMisalignment`) so reverting 
`DecodeFixed32`/`DecodeFixed64` does not introduce new test failures on 
big-endian ARM64 while keeping all tests active on little-endian targets.



##########
src/butil/crc32c.cc:
##########
@@ -829,6 +1226,16 @@ static inline Function Choose_Extend() {
     return (Function)ExtendImpl<FastCRC32Functor>;
   }
 #endif
+#if defined(__aarch64__)
+  if (isArmCrc32()) {
+#if defined(BUTIL_ARM64_PMULL_ENABLED)
+    if (isArmPmull()) {
+      return (Function)Arm64ExtendCrc32Pmull;
+    }
+#endif
+    return (Function)Arm64ExtendCrc32;

Review Comment:
   Update (`522e865a`): following the rolling-upgrade feedback in 
#discussion_r4715672988, `DecodeFixed32` and `DecodeFixed64` have been restored 
verbatim to `master` while `BUTIL_ARM64_CRC32_ENABLED` remains gated on 
little-endian ARM64. Big-endian ARM64 CPUs with and without `FEAT_CRC32` still 
run the exact same software path and remain wire-compatible with `master`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to