diff options
author | Sebastian Pop <s.pop@samsung.com> | 2019-01-23 13:15:33 -0600 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2019-01-31 13:56:00 +0100 |
commit | 39e68648c74b4d940f3df3edfd8a8e59b9f18963 (patch) | |
tree | fd74471c1de77904b5c54ee0d43faf6cef7985b3 /crc32.c | |
parent | deea1b8d3fce6f83e74540595264619b911e7a7b (diff) |
cleanup: move code from arch/x86/crc_pclmulqdq.c to crc32.c
Diffstat (limited to 'crc32.c')
-rw-r--r-- | crc32.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -400,16 +400,36 @@ uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t crc1, uint32_t crc2, z_off64_t return crc32_combine_(crc1, crc2, len2); } -#ifndef X86_PCLMULQDQ_CRC +#ifdef X86_PCLMULQDQ_CRC +#include "arch/x86/x86.h" +#include "arch/x86/crc_folding.h" + +ZLIB_INTERNAL void crc_finalize(deflate_state *const s) { + if (x86_cpu_has_pclmulqdq) + s->strm->adler = crc_fold_512to32(s); +} +#endif + ZLIB_INTERNAL void crc_reset(deflate_state *const s) { +#ifdef X86_PCLMULQDQ_CRC + if (x86_cpu_has_pclmulqdq) { + crc_fold_init(s); + return; + } +#endif s->strm->adler = PREFIX(crc32)(0L, NULL, 0); } ZLIB_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) { +#ifdef X86_PCLMULQDQ_CRC + if (x86_cpu_has_pclmulqdq) { + crc_fold_copy(strm->state, dst, strm->next_in, size); + return; + } +#endif memcpy(dst, strm->next_in, size); strm->adler = PREFIX(crc32)(strm->adler, dst, size); } -#endif /* ========================================================================= */ static void crc32_combine_gen_(uint32_t *op, z_off64_t len2) |