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

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

Issue 2676493007: NEON implementation for Adler32
Patch Set: Coding style. Created 3 years, 10 months 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/neon_adler32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* adler32.c -- compute the Adler-32 checksum of a data stream 1 /* adler32.c -- compute the Adler-32 checksum of a data stream
2 * Copyright (C) 1995-2011, 2016 Mark Adler 2 * Copyright (C) 1995-2011, 2016 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 5
6 /* @(#) $Id$ */ 6 /* @(#) $Id$ */
7 7
8 #include "zutil.h" 8 #include "zutil.h"
9 #ifdef __ARM_NEON__
10 #include "neon_adler32.h"
11 #endif
9 12
10 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 13 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
11 14
12 #define BASE 65521U /* largest prime smaller than 65536 */ 15 #define BASE 65521U /* largest prime smaller than 65536 */
13 #define NMAX 5552 16 #define NMAX 5552
14 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
15 18
16 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
17 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
18 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 # define MOD28(a) a %= BASE 61 # define MOD28(a) a %= BASE
59 # define MOD63(a) a %= BASE 62 # define MOD63(a) a %= BASE
60 #endif 63 #endif
61 64
62 /* ========================================================================= */ 65 /* ========================================================================= */
63 uLong ZEXPORT adler32_z(adler, buf, len) 66 uLong ZEXPORT adler32_z(adler, buf, len)
64 uLong adler; 67 uLong adler;
65 const Bytef *buf; 68 const Bytef *buf;
66 z_size_t len; 69 z_size_t len;
67 { 70 {
71 #ifdef __ARM_NEON__
72 if (len > 31)
73 return NEON_adler32(adler, buf, len);
74 #endif
75
68 unsigned long sum2; 76 unsigned long sum2;
69 unsigned n; 77 unsigned n;
70 78
71 /* split Adler-32 into component sums */ 79 /* split Adler-32 into component sums */
72 sum2 = (adler >> 16) & 0xffff; 80 sum2 = (adler >> 16) & 0xffff;
73 adler &= 0xffff; 81 adler &= 0xffff;
74 82
75 /* in case user likes doing a byte at a time, keep it fast */ 83 /* in case user likes doing a byte at a time, keep it fast */
76 if (len == 1) { 84 if (len == 1) {
77 adler += buf[0]; 85 adler += buf[0];
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return adler32_combine_(adler1, adler2, len2); 185 return adler32_combine_(adler1, adler2, len2);
178 } 186 }
179 187
180 uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 188 uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
181 uLong adler1; 189 uLong adler1;
182 uLong adler2; 190 uLong adler2;
183 z_off64_t len2; 191 z_off64_t len2;
184 { 192 {
185 return adler32_combine_(adler1, adler2, len2); 193 return adler32_combine_(adler1, adler2, len2);
186 } 194 }
OLDNEW
« no previous file with comments | « third_party/zlib/README.chromium ('k') | third_party/zlib/neon_adler32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698