diff --git a/src/blockstore/blockstore_journal.cpp b/src/blockstore/blockstore_journal.cpp index 9a20bd03..0830f44f 100644 --- a/src/blockstore/blockstore_journal.cpp +++ b/src/blockstore/blockstore_journal.cpp @@ -326,31 +326,3 @@ void journal_t::dump_diagnostics() journal_used_it == used_sectors.end() ? 0 : journal_used_it->second ); } - -static uint64_t zero_page[4096]; - -uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad) -{ - uint32_t r = prev_crc; - while (left_pad >= 4096) - { - r = crc32c(r, zero_page, 4096); - left_pad -= 4096; - } - if (left_pad > 0) - r = crc32c(r, zero_page, left_pad); - r = crc32c(r, buf, len); - while (right_pad >= 4096) - { - r = crc32c(r, zero_page, 4096); - right_pad -= 4096; - } - if (left_pad > 0) - r = crc32c(r, zero_page, right_pad); - return r; -} - -uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad) -{ - return crc32c(0, buf, len); -} diff --git a/src/blockstore/blockstore_journal.h b/src/blockstore/blockstore_journal.h index 4fea4d5a..1260ce85 100644 --- a/src/blockstore/blockstore_journal.h +++ b/src/blockstore/blockstore_journal.h @@ -216,6 +216,3 @@ struct blockstore_journal_check_t }; journal_entry* prefill_single_journal_entry(journal_t & journal, uint16_t type, uint32_t size); - -uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad); -uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad); diff --git a/src/util/crc32c.c b/src/util/crc32c.c index deba6f9c..4afdfd3e 100644 --- a/src/util/crc32c.c +++ b/src/util/crc32c.c @@ -372,3 +372,31 @@ uint32_t crc32c(uint32_t crc, const void *buf, size_t len) return sse42 ? crc32c_hw(crc, buf, len) : crc32c_sw(crc, buf, len); #endif } + +static uint8_t zero_page[4096] = {}; + +uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad) +{ + uint32_t r = prev_crc; + while (left_pad >= 4096) + { + r = crc32c(r, zero_page, 4096); + left_pad -= 4096; + } + if (left_pad > 0) + r = crc32c(r, zero_page, left_pad); + r = crc32c(r, buf, len); + while (right_pad >= 4096) + { + r = crc32c(r, zero_page, 4096); + right_pad -= 4096; + } + if (left_pad > 0) + r = crc32c(r, zero_page, right_pad); + return r; +} + +uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad) +{ + return crc32c(0, buf, len); +} diff --git a/src/util/crc32c.h b/src/util/crc32c.h index d8901a98..c5800939 100644 --- a/src/util/crc32c.h +++ b/src/util/crc32c.h @@ -12,6 +12,8 @@ extern "C" { #endif uint32_t crc32c(uint32_t crc, const void *buf, size_t len); +uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad); +uint32_t crc32c_nopad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad); #ifdef __cplusplus }; #endif