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

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

Issue 2676493007: NEON implementation for Adler32
Patch Set: 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
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 Mark Adler 2 * Copyright (C) 1995-2011 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 #define local static 13 #define local static
11 14
12 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 15 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
13 16
14 #define BASE 65521 /* largest prime smaller than 65536 */ 17 #define BASE 65521 /* largest prime smaller than 65536 */
15 #define NMAX 5552 18 #define NMAX 5552
16 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 19 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
17 20
18 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 21 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 # define MOD28(a) a %= BASE 63 # define MOD28(a) a %= BASE
61 # define MOD63(a) a %= BASE 64 # define MOD63(a) a %= BASE
62 #endif 65 #endif
63 66
64 /* ========================================================================= */ 67 /* ========================================================================= */
65 uLong ZEXPORT adler32(adler, buf, len) 68 uLong ZEXPORT adler32(adler, buf, len)
66 uLong adler; 69 uLong adler;
67 const Bytef *buf; 70 const Bytef *buf;
68 uInt len; 71 uInt len;
69 { 72 {
73 #ifdef __ARM_NEON__
74 if (len > 31) {
75 return NEON_adler32(adler, buf, len);
76 }
77 #endif
78
70 unsigned long sum2; 79 unsigned long sum2;
71 unsigned n; 80 unsigned n;
72 81
73 /* split Adler-32 into component sums */ 82 /* split Adler-32 into component sums */
74 sum2 = (adler >> 16) & 0xffff; 83 sum2 = (adler >> 16) & 0xffff;
75 adler &= 0xffff; 84 adler &= 0xffff;
76 85
77 /* in case user likes doing a byte at a time, keep it fast */ 86 /* in case user likes doing a byte at a time, keep it fast */
78 if (len == 1) { 87 if (len == 1) {
79 adler += buf[0]; 88 adler += buf[0];
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return adler32_combine_(adler1, adler2, len2); 179 return adler32_combine_(adler1, adler2, len2);
171 } 180 }
172 181
173 uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 182 uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
174 uLong adler1; 183 uLong adler1;
175 uLong adler2; 184 uLong adler2;
176 z_off64_t len2; 185 z_off64_t len2;
177 { 186 {
178 return adler32_combine_(adler1, adler2, len2); 187 return adler32_combine_(adler1, adler2, len2);
179 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698