Delegate crc32 calculation to abseil To reduce number of third_party dependencies of the dcsctp library. Bug: None Change-Id: I251d24cc214860342abcc73cdadaf61e3cd02941 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/452180 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Victor Boivie <boivie@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47034}
diff --git a/DEPS b/DEPS index 98f788e..8451e1b 100644 --- a/DEPS +++ b/DEPS
@@ -1352,6 +1352,7 @@ "+absl/cleanup/cleanup.h", "+absl/container", "-absl/container/fixed_array.h", + "+absl/crc", "+absl/functional/any_invocable.h", "+absl/functional/bind_front.h", "+absl/memory/memory.h",
diff --git a/g3doc/abseil-in-webrtc.md b/g3doc/abseil-in-webrtc.md index af305cb..fd74182 100644 --- a/g3doc/abseil-in-webrtc.md +++ b/g3doc/abseil-in-webrtc.md
@@ -40,6 +40,7 @@ * The macros in `absl/base/attributes.h`, `absl/base/config.h` and `absl/base/macros.h`. * `absl/numeric/bits.h` +* `absl/crc` * Single argument `absl::StrCat` * ABSL_FLAG is allowed in tests and tools, but disallowed in in non-test code.
diff --git a/net/dcsctp/packet/BUILD.gn b/net/dcsctp/packet/BUILD.gn index e924893..852788b 100644 --- a/net/dcsctp/packet/BUILD.gn +++ b/net/dcsctp/packet/BUILD.gn
@@ -47,7 +47,9 @@ rtc_library("crc32c") { deps = [ "../../../api:array_view", - "//third_party/crc32c", + "//third_party/abseil-cpp/absl/crc:crc32c", + "//third_party/abseil-cpp/absl/numeric:bits", + "//third_party/abseil-cpp/absl/strings:string_view", ] sources = [ "crc32c.cc",
diff --git a/net/dcsctp/packet/DEPS b/net/dcsctp/packet/DEPS deleted file mode 100644 index 206b405..0000000 --- a/net/dcsctp/packet/DEPS +++ /dev/null
@@ -1,3 +0,0 @@ -include_rules = [ - "+third_party/crc32c", -]
diff --git a/net/dcsctp/packet/crc32c.cc b/net/dcsctp/packet/crc32c.cc index 8318b0d..a55749b 100644 --- a/net/dcsctp/packet/crc32c.cc +++ b/net/dcsctp/packet/crc32c.cc
@@ -11,20 +11,16 @@ #include <cstdint> +#include "absl/crc/crc32c.h" +#include "absl/numeric/bits.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "third_party/crc32c/src/include/crc32c/crc32c.h" namespace dcsctp { uint32_t GenerateCrc32C(webrtc::ArrayView<const uint8_t> data) { - uint32_t crc32c = crc32c_value(data.data(), data.size()); - - // Byte swapping for little endian byte order: - uint8_t byte0 = crc32c; - uint8_t byte1 = crc32c >> 8; - uint8_t byte2 = crc32c >> 16; - uint8_t byte3 = crc32c >> 24; - crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3); - return crc32c; + absl::crc32c_t crc32 = absl::ComputeCrc32c(absl::string_view( + reinterpret_cast<const char*>(data.data()), data.size())); + return absl::byteswap(static_cast<uint32_t>(crc32)); } } // namespace dcsctp