mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 14:16:12 +00:00
Expose CRC-32 implementation from zlib
llvm-svn: 188380
This commit is contained in:
parent
1a2916808e
commit
235b9a341c
@ -50,6 +50,8 @@ Status uncompress(StringRef InputBuffer,
|
||||
OwningPtr<MemoryBuffer> &UncompressedBuffer,
|
||||
size_t UncompressedSize);
|
||||
|
||||
uint32_t crc32(StringRef Buffer);
|
||||
|
||||
} // End of namespace zlib
|
||||
|
||||
} // End of namespace llvm
|
||||
|
@ -81,6 +81,10 @@ zlib::Status zlib::uncompress(StringRef InputBuffer,
|
||||
return Res;
|
||||
}
|
||||
|
||||
uint32_t zlib::crc32(StringRef Buffer) {
|
||||
return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
|
||||
}
|
||||
|
||||
#else
|
||||
bool zlib::isAvailable() { return false; }
|
||||
zlib::Status zlib::compress(StringRef InputBuffer,
|
||||
@ -93,5 +97,8 @@ zlib::Status zlib::uncompress(StringRef InputBuffer,
|
||||
size_t UncompressedSize) {
|
||||
return zlib::StatusUnsupported;
|
||||
}
|
||||
uint32_t zlib::crc32(StringRef Buffer) {
|
||||
llvm_unreachable("zlib::crc32 is unavailable");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -63,6 +63,12 @@ TEST(CompressionTest, Zlib) {
|
||||
TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
|
||||
}
|
||||
|
||||
TEST(CompressionTest, ZlibCRC32) {
|
||||
EXPECT_EQ(
|
||||
0x414FA339U,
|
||||
zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user