Line | Count | Source |
1 | | /* adler32_p.h -- Private inline functions and macros shared with |
2 | | * different computation of the Adler-32 checksum |
3 | | * of a data stream. |
4 | | * Copyright (C) 1995-2011, 2016 Mark Adler |
5 | | * For conditions of distribution and use, see copyright notice in zlib.h |
6 | | */ |
7 | | |
8 | | #ifndef ADLER32_P_H |
9 | | #define ADLER32_P_H |
10 | | |
11 | 342k | #define BASE 65521U /* largest prime smaller than 65536 */ |
12 | 2.74k | #define NMAX 5552 |
13 | | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
14 | | |
15 | 0 | #define ADLER_DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);} |
16 | 0 | #define ADLER_DO2(sum1, sum2, buf, i) {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);} |
17 | 0 | #define ADLER_DO4(sum1, sum2, buf, i) {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);} |
18 | 0 | #define ADLER_DO8(sum1, sum2, buf, i) {ADLER_DO4(sum1, sum2, buf, i); ADLER_DO4(sum1, sum2, buf, i+4);} |
19 | | #define ADLER_DO16(sum1, sum2, buf) {ADLER_DO8(sum1, sum2, buf, 0); ADLER_DO8(sum1, sum2, buf, 8);} |
20 | | |
21 | 0 | static inline uint32_t adler32_copy_len_1(uint32_t adler, uint8_t *dst, const uint8_t *buf, uint32_t sum2, const int COPY) { |
22 | 0 | uint8_t c = *buf; |
23 | 0 | if (COPY) { |
24 | 0 | *dst = c; |
25 | 0 | } |
26 | 0 | adler += c; |
27 | 0 | adler %= BASE; |
28 | 0 | sum2 += adler; |
29 | 0 | sum2 %= BASE; |
30 | 0 | return adler | (sum2 << 16); |
31 | 0 | } Unexecuted instantiation: adler32_ssse3.c:adler32_copy_len_1 Unexecuted instantiation: adler32_sse42.c:adler32_copy_len_1 Unexecuted instantiation: adler32_avx2.c:adler32_copy_len_1 Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_1 Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_1 Unexecuted instantiation: adler32_c.c:adler32_copy_len_1 |
32 | | |
33 | 9.03k | static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) { |
34 | 76.6k | while (len--) { |
35 | 67.6k | uint8_t c = *buf++; |
36 | 67.6k | if (COPY) { |
37 | 48.5k | *dst++ = c; |
38 | 48.5k | } |
39 | 67.6k | adler += c; |
40 | 67.6k | sum2 += adler; |
41 | 67.6k | } |
42 | 9.03k | adler %= BASE; |
43 | 9.03k | sum2 %= BASE; /* only added so many BASE's */ |
44 | | /* return recombined sums */ |
45 | 9.03k | return adler | (sum2 << 16); |
46 | 9.03k | } adler32_ssse3.c:adler32_copy_len_16 Line | Count | Source | 33 | 1.37k | static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) { | 34 | 10.2k | while (len--) { | 35 | 8.84k | uint8_t c = *buf++; | 36 | 8.84k | if (COPY) { | 37 | 0 | *dst++ = c; | 38 | 0 | } | 39 | 8.84k | adler += c; | 40 | 8.84k | sum2 += adler; | 41 | 8.84k | } | 42 | 1.37k | adler %= BASE; | 43 | 1.37k | sum2 %= BASE; /* only added so many BASE's */ | 44 | | /* return recombined sums */ | 45 | 1.37k | return adler | (sum2 << 16); | 46 | 1.37k | } |
adler32_sse42.c:adler32_copy_len_16 Line | Count | Source | 33 | 3.22k | static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) { | 34 | 28.4k | while (len--) { | 35 | 25.1k | uint8_t c = *buf++; | 36 | 25.1k | if (COPY) { | 37 | 25.1k | *dst++ = c; | 38 | 25.1k | } | 39 | 25.1k | adler += c; | 40 | 25.1k | sum2 += adler; | 41 | 25.1k | } | 42 | 3.22k | adler %= BASE; | 43 | 3.22k | sum2 %= BASE; /* only added so many BASE's */ | 44 | | /* return recombined sums */ | 45 | 3.22k | return adler | (sum2 << 16); | 46 | 3.22k | } |
adler32_avx2.c:adler32_copy_len_16 Line | Count | Source | 33 | 4.43k | static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) { | 34 | 38.0k | while (len--) { | 35 | 33.5k | uint8_t c = *buf++; | 36 | 33.5k | if (COPY) { | 37 | 23.3k | *dst++ = c; | 38 | 23.3k | } | 39 | 33.5k | adler += c; | 40 | 33.5k | sum2 += adler; | 41 | 33.5k | } | 42 | 4.43k | adler %= BASE; | 43 | 4.43k | sum2 %= BASE; /* only added so many BASE's */ | 44 | | /* return recombined sums */ | 45 | 4.43k | return adler | (sum2 << 16); | 46 | 4.43k | } |
Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_16 Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_16 Unexecuted instantiation: adler32_c.c:adler32_copy_len_16 |
47 | | |
48 | 0 | static inline uint32_t adler32_copy_len_64(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) { |
49 | 0 | const uint8_t *src = buf; |
50 | 0 | const size_t src_len = len; |
51 | | #ifdef UNROLL_MORE |
52 | | while (len >= 16) { |
53 | | len -= 16; |
54 | | ADLER_DO16(adler, sum2, buf); |
55 | | buf += 16; |
56 | | #else |
57 | 0 | while (len >= 8) { |
58 | 0 | len -= 8; |
59 | 0 | ADLER_DO8(adler, sum2, buf, 0); |
60 | 0 | buf += 8; |
61 | 0 | #endif |
62 | 0 | } |
63 | | /* Process tail (len < 16). */ |
64 | 0 | adler = adler32_copy_len_16(adler, NULL, buf, len, sum2, 0); |
65 | 0 | if (COPY) { |
66 | 0 | memcpy(dst, src, src_len); |
67 | 0 | } |
68 | 0 | return adler; |
69 | 0 | } Unexecuted instantiation: adler32_ssse3.c:adler32_copy_len_64 Unexecuted instantiation: adler32_sse42.c:adler32_copy_len_64 Unexecuted instantiation: adler32_avx2.c:adler32_copy_len_64 Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_64 Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_64 Unexecuted instantiation: adler32_c.c:adler32_copy_len_64 |
70 | | |
71 | | #endif /* ADLER32_P_H */ |