OLD | NEW |
---|---|
1 /* crc32.c -- compute the CRC-32 of a data stream | 1 /* crc32.c -- compute the CRC-32 of a data stream |
2 * Copyright (C) 1995-2006, 2010 Mark Adler | 2 * Copyright (C) 1995-2006, 2010 Mark Adler |
3 * For conditions of distribution and use, see copyright notice in zlib.h | 3 * For conditions of distribution and use, see copyright notice in zlib.h |
4 * | 4 * |
5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster | 5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster |
6 * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing | 6 * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing |
7 * tables for updating the shift register in one step with three exclusive-ors | 7 * tables for updating the shift register in one step with three exclusive-ors |
8 * instead of four steps with four exclusive-ors. This results in about a | 8 * instead of four steps with four exclusive-ors. This results in about a |
9 * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. | 9 * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. |
10 */ | 10 */ |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 return crc32_combine_(crc1, crc2, len2); | 433 return crc32_combine_(crc1, crc2, len2); |
434 } | 434 } |
435 | 435 |
436 uLong ZEXPORT crc32_combine64(crc1, crc2, len2) | 436 uLong ZEXPORT crc32_combine64(crc1, crc2, len2) |
437 uLong crc1; | 437 uLong crc1; |
438 uLong crc2; | 438 uLong crc2; |
439 z_off64_t len2; | 439 z_off64_t len2; |
440 { | 440 { |
441 return crc32_combine_(crc1, crc2, len2); | 441 return crc32_combine_(crc1, crc2, len2); |
442 } | 442 } |
443 | |
444 #include "deflate.h" | |
agl
2014/09/23 21:41:39
don't #include in the middle of the file if it can
| |
445 | |
446 #ifdef HAVE_PCLMULQDQ | |
447 #include "x86.h" | |
448 extern void ZLIB_INTERNAL crc_fold_init(deflate_state *const s); | |
449 extern void ZLIB_INTERNAL crc_fold_copy(deflate_state *const s, | |
450 unsigned char *dst, const unsigned char *src, long len); | |
451 extern unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s); | |
452 #endif | |
453 | |
454 ZLIB_INTERNAL void crc_reset(deflate_state *const s) | |
455 { | |
456 #ifdef HAVE_PCLMULQDQ | |
457 if (x86_cpu_has_pclmulqdq) { | |
458 crc_fold_init(s); | |
459 return; | |
460 } | |
461 #endif | |
462 s->strm->adler = crc32(0L, Z_NULL, 0); | |
463 } | |
464 | |
465 ZLIB_INTERNAL void crc_finalize(deflate_state *const s) | |
466 { | |
467 #ifdef HAVE_PCLMULQDQ | |
468 if (x86_cpu_has_pclmulqdq) | |
469 s->strm->adler = crc_fold_512to32(s); | |
470 #endif | |
471 } | |
472 | |
473 ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size) | |
474 { | |
475 #ifdef HAVE_PCLMULQDQ | |
476 if (x86_cpu_has_pclmulqdq) { | |
477 crc_fold_copy(strm->state, dst, strm->next_in, size); | |
478 return; | |
479 } | |
480 #endif | |
481 zmemcpy(dst, strm->next_in, size); | |
482 strm->adler = crc32(strm->adler, dst, size); | |
483 } | |
484 | |
agl
2014/09/23 21:41:39
no blank line at end of file.
| |
OLD | NEW |