Chromium Code Reviews| Index: third_party/zlib/crc32.c |
| diff --git a/third_party/zlib/crc32.c b/third_party/zlib/crc32.c |
| index 91be372d224da6833c03bd24d7158ff622ece35f..4aa396b2f6a96398dee87e3748dc620093ed2092 100644 |
| --- a/third_party/zlib/crc32.c |
| +++ b/third_party/zlib/crc32.c |
| @@ -440,3 +440,45 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2) |
| { |
| return crc32_combine_(crc1, crc2, len2); |
| } |
| + |
| +#include "deflate.h" |
|
agl
2014/09/23 21:41:39
don't #include in the middle of the file if it can
|
| + |
| +#ifdef HAVE_PCLMULQDQ |
| +#include "x86.h" |
| +extern void ZLIB_INTERNAL crc_fold_init(deflate_state *const s); |
| +extern void ZLIB_INTERNAL crc_fold_copy(deflate_state *const s, |
| + unsigned char *dst, const unsigned char *src, long len); |
| +extern unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s); |
| +#endif |
| + |
| +ZLIB_INTERNAL void crc_reset(deflate_state *const s) |
| +{ |
| +#ifdef HAVE_PCLMULQDQ |
| + if (x86_cpu_has_pclmulqdq) { |
| + crc_fold_init(s); |
| + return; |
| + } |
| +#endif |
| + s->strm->adler = crc32(0L, Z_NULL, 0); |
| +} |
| + |
| +ZLIB_INTERNAL void crc_finalize(deflate_state *const s) |
| +{ |
| +#ifdef HAVE_PCLMULQDQ |
| + if (x86_cpu_has_pclmulqdq) |
| + s->strm->adler = crc_fold_512to32(s); |
| +#endif |
| +} |
| + |
| +ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size) |
| +{ |
| +#ifdef HAVE_PCLMULQDQ |
| + if (x86_cpu_has_pclmulqdq) { |
| + crc_fold_copy(strm->state, dst, strm->next_in, size); |
| + return; |
| + } |
| +#endif |
| + zmemcpy(dst, strm->next_in, size); |
| + strm->adler = crc32(strm->adler, dst, size); |
| +} |
| + |
|
agl
2014/09/23 21:41:39
no blank line at end of file.
|