Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: third_party/zlib/crc32.c

Issue 665203006: Revert of Reland "Integrate SIMD optimisations for zlib" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/zlib/README.chromium ('k') | third_party/zlib/crc_folding.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 */
11 11
12 /* @(#) $Id$ */ 12 /* @(#) $Id$ */
13 13
14 /* 14 /*
15 Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore 15 Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
16 protection on the static variables used to control the first-use generation 16 protection on the static variables used to control the first-use generation
17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should 17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
18 first call get_crc_table() to initialize the tables before allowing more than 18 first call get_crc_table() to initialize the tables before allowing more than
19 one thread to use crc32(). 19 one thread to use crc32().
20 */ 20 */
21 21
22 #ifdef MAKECRCH 22 #ifdef MAKECRCH
23 # include <stdio.h> 23 # include <stdio.h>
24 # ifndef DYNAMIC_CRC_TABLE 24 # ifndef DYNAMIC_CRC_TABLE
25 # define DYNAMIC_CRC_TABLE 25 # define DYNAMIC_CRC_TABLE
26 # endif /* !DYNAMIC_CRC_TABLE */ 26 # endif /* !DYNAMIC_CRC_TABLE */
27 #endif /* MAKECRCH */ 27 #endif /* MAKECRCH */
28 28
29 #include "deflate.h"
30 #include "x86.h"
31 #include "zutil.h" /* for STDC and FAR definitions */ 29 #include "zutil.h" /* for STDC and FAR definitions */
32 30
33 #define local static 31 #define local static
34 32
35 /* Find a four-byte integer type for crc32_little() and crc32_big(). */ 33 /* Find a four-byte integer type for crc32_little() and crc32_big(). */
36 #ifndef NOBYFOUR 34 #ifndef NOBYFOUR
37 # ifdef STDC /* need ANSI C limits.h to determine sizes */ 35 # ifdef STDC /* need ANSI C limits.h to determine sizes */
38 # include <limits.h> 36 # include <limits.h>
39 # define BYFOUR 37 # define BYFOUR
40 # if (UINT_MAX == 0xffffffffUL) 38 # if (UINT_MAX == 0xffffffffUL)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return crc32_combine_(crc1, crc2, len2); 433 return crc32_combine_(crc1, crc2, len2);
436 } 434 }
437 435
438 uLong ZEXPORT crc32_combine64(crc1, crc2, len2) 436 uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
439 uLong crc1; 437 uLong crc1;
440 uLong crc2; 438 uLong crc2;
441 z_off64_t len2; 439 z_off64_t len2;
442 { 440 {
443 return crc32_combine_(crc1, crc2, len2); 441 return crc32_combine_(crc1, crc2, len2);
444 } 442 }
445
446 ZLIB_INTERNAL void crc_reset(deflate_state *const s)
447 {
448 if (x86_cpu_enable_simd) {
449 crc_fold_init(s);
450 return;
451 }
452 s->strm->adler = crc32(0L, Z_NULL, 0);
453 }
454
455 ZLIB_INTERNAL void crc_finalize(deflate_state *const s)
456 {
457 if (x86_cpu_enable_simd)
458 s->strm->adler = crc_fold_512to32(s);
459 }
460
461 ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size)
462 {
463 if (x86_cpu_enable_simd) {
464 crc_fold_copy(strm->state, dst, strm->next_in, size);
465 return;
466 }
467 zmemcpy(dst, strm->next_in, size);
468 strm->adler = crc32(strm->adler, dst, size);
469 }
OLDNEW
« no previous file with comments | « third_party/zlib/README.chromium ('k') | third_party/zlib/crc_folding.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698