llvm.org GIT mirror llvm / ef7aefc
Expose CRC-32 implementation from zlib git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188380 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
3 changed file(s) with 15 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4949 OwningPtr &UncompressedBuffer,
5050 size_t UncompressedSize);
5151
52 uint32_t crc32(StringRef Buffer);
53
5254 } // End of namespace zlib
5355
5456 } // End of namespace llvm
8080 return Res;
8181 }
8282
83 uint32_t zlib::crc32(StringRef Buffer) {
84 return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
85 }
86
8387 #else
8488 bool zlib::isAvailable() { return false; }
8589 zlib::Status zlib::compress(StringRef InputBuffer,
9296 size_t UncompressedSize) {
9397 return zlib::StatusUnsupported;
9498 }
99 uint32_t zlib::crc32(StringRef Buffer) {
100 llvm_unreachable("zlib::crc32 is unavailable");
101 }
95102 #endif
96103
6262 TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
6363 }
6464
65 TEST(CompressionTest, ZlibCRC32) {
66 EXPECT_EQ(
67 0x414FA339U,
68 zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
69 }
70
6571 #endif
6672
6773 }