diff options
Diffstat (limited to 'xdelta3')
-rwxr-xr-x | xdelta3/run_release.sh | 10 | ||||
-rw-r--r-- | xdelta3/testing/checksum_test.cc | 82 | ||||
-rw-r--r-- | xdelta3/xdelta3-hash.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3.c | 2 |
4 files changed, 27 insertions, 71 deletions
diff --git a/xdelta3/run_release.sh b/xdelta3/run_release.sh index 7e841ab..8e99c6b 100755 --- a/xdelta3/run_release.sh +++ b/xdelta3/run_release.sh | |||
@@ -4,15 +4,15 @@ | |||
4 | CC=clang | 4 | CC=clang |
5 | CXX=clang++ | 5 | CXX=clang++ |
6 | # or | 6 | # or |
7 | #CC=gcc | 7 | CC=gcc |
8 | #CXX=g++ | 8 | CXX=g++ |
9 | 9 | ||
10 | # These are updated below, | 10 | # These are updated below, |
11 | CFLAGS= # Do not set here | 11 | CFLAGS= # Do not set here |
12 | CXXFLAGS= # Do not set here | 12 | CXXFLAGS= # Do not set here |
13 | 13 | ||
14 | # Place C/C++ common flags here | 14 | # Place C/C++ common flags here |
15 | #COMMON=-O3 | 15 | COMMON=-O3 |
16 | 16 | ||
17 | export CFLAGS | 17 | export CFLAGS |
18 | export CXXFLAGS | 18 | export CXXFLAGS |
@@ -53,9 +53,7 @@ function buildit { | |||
53 | D=build/$MACH/${sizebits}size-${offsetbits}off | 53 | D=build/$MACH/${sizebits}size-${offsetbits}off |
54 | mkdir -p $D | 54 | mkdir -p $D |
55 | (cd $D && $SRCDIR/configure --prefix=$PWD/bin --enable-debug-symbols) | 55 | (cd $D && $SRCDIR/configure --prefix=$PWD/bin --enable-debug-symbols) |
56 | #(cd $D && make all) | 56 | (cd $D && make all) |
57 | #echo Running regtest. | ||
58 | #(cd $D && ./xdelta3regtest) | ||
59 | } | 57 | } |
60 | 58 | ||
61 | function buildall { | 59 | function buildall { |
diff --git a/xdelta3/testing/checksum_test.cc b/xdelta3/testing/checksum_test.cc index 353d705..53566b9 100644 --- a/xdelta3/testing/checksum_test.cc +++ b/xdelta3/testing/checksum_test.cc | |||
@@ -176,9 +176,9 @@ struct with_stream : public cksum_params<SELF> { | |||
176 | }; | 176 | }; |
177 | 177 | ||
178 | MEMBER | 178 | MEMBER |
179 | struct large64_cksum : public with_stream<SELF> { | 179 | struct large_cksum : public with_stream<SELF> { |
180 | Word step(const uint8_t *ptr) { | 180 | Word step(const uint8_t *ptr) { |
181 | return xd3_large64_cksum (&this->stream.large_hash, ptr, CksumSize); | 181 | return xd3_large_cksum (&this->stream.large_hash, ptr, CksumSize); |
182 | } | 182 | } |
183 | 183 | ||
184 | Word state0(const uint8_t *ptr) { | 184 | Word state0(const uint8_t *ptr) { |
@@ -187,36 +187,26 @@ struct large64_cksum : public with_stream<SELF> { | |||
187 | } | 187 | } |
188 | 188 | ||
189 | Word incr(const uint8_t *ptr) { | 189 | Word incr(const uint8_t *ptr) { |
190 | incr_state = xd3_large64_cksum_update (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | 190 | incr_state = xd3_large_cksum_update (&this->stream.large_hash, |
191 | incr_state, ptr - 1, CksumSize); | ||
191 | return incr_state; | 192 | return incr_state; |
192 | } | 193 | } |
193 | 194 | ||
194 | Word incr_state; | 195 | Word incr_state; |
195 | }; | 196 | }; |
196 | 197 | ||
197 | MEMBER | 198 | #if SIZEOF_USIZE_T == 4 |
198 | struct large64_cksum_old : public with_stream<SELF> { | 199 | #define xd3_large_cksum_old xd3_large32_cksum_old |
199 | Word step(const uint8_t *ptr) { | 200 | #define xd3_large_cksum_update_old xd3_large32_cksum_update_old |
200 | return xd3_large64_cksum_old (&this->stream.large_hash, ptr, CksumSize); | 201 | #elif SIZEOF_USIZE_T == 8 |
201 | } | 202 | #define xd3_large_cksum_old xd3_large64_cksum_old |
202 | 203 | #define xd3_large_cksum_update_old xd3_large64_cksum_update_old | |
203 | Word state0(const uint8_t *ptr) { | 204 | #endif |
204 | incr_state = step(ptr); | ||
205 | return incr_state; | ||
206 | } | ||
207 | |||
208 | Word incr(const uint8_t *ptr) { | ||
209 | incr_state = xd3_large64_cksum_update_old (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | ||
210 | return incr_state; | ||
211 | } | ||
212 | |||
213 | Word incr_state; | ||
214 | }; | ||
215 | 205 | ||
216 | MEMBER | 206 | MEMBER |
217 | struct large32_cksum : public with_stream<SELF> { | 207 | struct large_cksum_old : public with_stream<SELF> { |
218 | Word step(const uint8_t *ptr) { | 208 | Word step(const uint8_t *ptr) { |
219 | return xd3_large32_cksum (&this->stream.large_hash, ptr, CksumSize); | 209 | return xd3_large_cksum_old (&this->stream.large_hash, ptr, CksumSize); |
220 | } | 210 | } |
221 | 211 | ||
222 | Word state0(const uint8_t *ptr) { | 212 | Word state0(const uint8_t *ptr) { |
@@ -225,48 +215,14 @@ struct large32_cksum : public with_stream<SELF> { | |||
225 | } | 215 | } |
226 | 216 | ||
227 | Word incr(const uint8_t *ptr) { | 217 | Word incr(const uint8_t *ptr) { |
228 | incr_state = xd3_large32_cksum_update (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | 218 | incr_state = xd3_large_cksum_update_old (&this->stream.large_hash, |
219 | incr_state, ptr - 1, CksumSize); | ||
229 | return incr_state; | 220 | return incr_state; |
230 | } | 221 | } |
231 | 222 | ||
232 | Word incr_state; | 223 | Word incr_state; |
233 | }; | 224 | }; |
234 | 225 | ||
235 | MEMBER | ||
236 | struct large32_cksum_old : public with_stream<SELF> { | ||
237 | Word step(const uint8_t *ptr) { | ||
238 | return xd3_large32_cksum_old (&this->stream.large_hash, ptr, CksumSize); | ||
239 | } | ||
240 | |||
241 | Word state0(const uint8_t *ptr) { | ||
242 | incr_state = step(ptr); | ||
243 | return incr_state; | ||
244 | } | ||
245 | |||
246 | Word incr(const uint8_t *ptr) { | ||
247 | incr_state = xd3_large32_cksum_update_old (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | ||
248 | return incr_state; | ||
249 | } | ||
250 | |||
251 | Word incr_state; | ||
252 | }; | ||
253 | |||
254 | MEMBER | ||
255 | struct large_cksum | ||
256 | : std::conditional<std::is_same<Word, uint32_t>::value, | ||
257 | large32_cksum<SELF>, | ||
258 | large64_cksum<SELF>>::type | ||
259 | { | ||
260 | }; | ||
261 | |||
262 | MEMBER | ||
263 | struct large_cksum_old | ||
264 | : std::conditional<std::is_same<Word, uint32_t>::value, | ||
265 | large32_cksum_old<SELF>, | ||
266 | large64_cksum_old<SELF>>::type | ||
267 | { | ||
268 | }; | ||
269 | |||
270 | // TESTS | 226 | // TESTS |
271 | 227 | ||
272 | template <typename Word> | 228 | template <typename Word> |
@@ -717,11 +673,9 @@ int main(int argc, char** argv) { | |||
717 | _old_ ## T ## _ ## Z ## _ ## S ## _ ## C \ | 673 | _old_ ## T ## _ ## Z ## _ ## S ## _ ## C \ |
718 | ("old_" #T "_" #Z "_" #S "_" #C) | 674 | ("old_" #T "_" #Z "_" #S "_" #C) |
719 | 675 | ||
720 | #define TESTS(SIZE, SKIP) \ | 676 | #define TESTS(SIZE, SKIP) \ |
721 | TEST(uint32_t, SIZE, SKIP, 1); \ | 677 | TEST(usize_t, SIZE, SKIP, 1); \ |
722 | TEST(uint32_t, SIZE, SKIP, 2); \ | 678 | TEST(usize_t, SIZE, SKIP, 2) |
723 | TEST(uint64_t, SIZE, SKIP, 1); \ | ||
724 | TEST(uint64_t, SIZE, SKIP, 2) | ||
725 | 679 | ||
726 | TESTS(9, 1); | 680 | TESTS(9, 1); |
727 | TESTS(9, 9); | 681 | TESTS(9, 9); |
diff --git a/xdelta3/xdelta3-hash.h b/xdelta3/xdelta3-hash.h index 2919b98..c112b5a 100644 --- a/xdelta3/xdelta3-hash.h +++ b/xdelta3/xdelta3-hash.h | |||
@@ -72,6 +72,7 @@ xd3_checksum_hash (const xd3_hash_cfg *cfg, const usize_t cksum) | |||
72 | return (cksum >> cfg->shift) ^ (cksum & cfg->mask); | 72 | return (cksum >> cfg->shift) ^ (cksum & cfg->mask); |
73 | } | 73 | } |
74 | 74 | ||
75 | #if SIZEOF_USIZE_T == 4 | ||
75 | inline uint32_t | 76 | inline uint32_t |
76 | xd3_large32_cksum (xd3_hash_cfg *cfg, const uint8_t *base, const usize_t look) | 77 | xd3_large32_cksum (xd3_hash_cfg *cfg, const uint8_t *base, const usize_t look) |
77 | { | 78 | { |
@@ -88,7 +89,9 @@ xd3_large32_cksum_update (xd3_hash_cfg *cfg, const uint32_t cksum, | |||
88 | { | 89 | { |
89 | return xd3_hash_multiplier32 * cksum - cfg->multiplier * base[0] + base[look]; | 90 | return xd3_hash_multiplier32 * cksum - cfg->multiplier * base[0] + base[look]; |
90 | } | 91 | } |
92 | #endif | ||
91 | 93 | ||
94 | #if SIZEOF_USIZE_T == 8 | ||
92 | inline uint64_t | 95 | inline uint64_t |
93 | xd3_large64_cksum (xd3_hash_cfg *cfg, const uint8_t *base, const usize_t look) | 96 | xd3_large64_cksum (xd3_hash_cfg *cfg, const uint8_t *base, const usize_t look) |
94 | { | 97 | { |
@@ -105,6 +108,7 @@ xd3_large64_cksum_update (xd3_hash_cfg *cfg, const uint64_t cksum, | |||
105 | { | 108 | { |
106 | return xd3_hash_multiplier64 * cksum - cfg->multiplier * base[0] + base[look]; | 109 | return xd3_hash_multiplier64 * cksum - cfg->multiplier * base[0] + base[look]; |
107 | } | 110 | } |
111 | #endif | ||
108 | 112 | ||
109 | static usize_t | 113 | static usize_t |
110 | xd3_size_hashtable_bits (usize_t slots) | 114 | xd3_size_hashtable_bits (usize_t slots) |
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 5c79f37..612e747 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -2174,7 +2174,7 @@ xd3_set_source (xd3_stream *stream, | |||
2174 | } | 2174 | } |
2175 | 2175 | ||
2176 | src->shiftby = shiftby; | 2176 | src->shiftby = shiftby; |
2177 | src->maskby = (1 << shiftby) - 1; | 2177 | src->maskby = (1ULL << shiftby) - 1ULL; |
2178 | 2178 | ||
2179 | if (xd3_check_pow2 (src->max_winsize, NULL) != 0) | 2179 | if (xd3_check_pow2 (src->max_winsize, NULL) != 0) |
2180 | { | 2180 | { |