zstdlib 0.6.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -0
- data/README.md +7 -1
- data/Rakefile +38 -8
- data/ext/{zstdlib → zstdlib_c}/extconf.rb +10 -5
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/adler32.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/compress.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzclose.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzguts.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzlib.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzread.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzwrite.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/infback.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffixed.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/uncompr.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zconf.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zlib.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.c +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.h +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +75 -57
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +1 -3
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.c +24 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +22 -49
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +3 -1
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +51 -42
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +149 -57
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +60 -54
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +87 -98
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +34 -23
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +5 -5
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +10 -8
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +4 -3
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +10 -10
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_internal.h +493 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +105 -85
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +41 -63
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +13 -33
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress.c +6327 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +537 -82
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +21 -16
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +4 -2
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +61 -34
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +10 -3
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.c +573 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +236 -95
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +321 -143
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +2 -2
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +328 -137
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +2 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +336 -209
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +15 -3
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +439 -239
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +1 -1
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +205 -462
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress.c +1889 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +20 -16
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +3 -3
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +691 -230
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.c +2072 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +16 -7
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +71 -10
- data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +760 -234
- data/ext/{zstdlib/zstd-1.4.4/lib/common → zstdlib_c/zstd-1.5.2/lib}/zstd_errors.h +3 -1
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +1 -1
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +133 -44
- data/ext/{zstdlib/zstd-1.4.4 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +1 -1
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/zstdlib.rb +2 -2
- metadata +118 -107
- data/ext/zstdlib/zstd-1.4.4/lib/common/compiler.h +0 -159
- data/ext/zstdlib/zstd-1.4.4/lib/common/debug.c +0 -44
- data/ext/zstdlib/zstd-1.4.4/lib/common/entropy_common.c +0 -236
- data/ext/zstdlib/zstd-1.4.4/lib/common/error_private.h +0 -76
- data/ext/zstdlib/zstd-1.4.4/lib/common/xxhash.c +0 -882
- data/ext/zstdlib/zstd-1.4.4/lib/common/xxhash.h +0 -305
- data/ext/zstdlib/zstd-1.4.4/lib/common/zstd_internal.h +0 -350
- data/ext/zstdlib/zstd-1.4.4/lib/compress/huf_compress.c +0 -798
- data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_compress.c +0 -4103
- data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_lazy.c +0 -1115
- data/ext/zstdlib/zstd-1.4.4/lib/compress/zstd_lazy.h +0 -67
- data/ext/zstdlib/zstd-1.4.4/lib/compress/zstdmt_compress.h +0 -192
- data/ext/zstdlib/zstd-1.4.4/lib/decompress/huf_decompress.c +0 -1234
- data/ext/zstdlib/zstd-1.4.4/lib/decompress/zstd_decompress_block.c +0 -1323
- data/ext/zstdlib/zstd.mk +0 -14
@@ -1,305 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
xxHash - Extremely Fast Hash algorithm
|
3
|
-
Header File
|
4
|
-
Copyright (C) 2012-2016, Yann Collet.
|
5
|
-
|
6
|
-
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
7
|
-
|
8
|
-
Redistribution and use in source and binary forms, with or without
|
9
|
-
modification, are permitted provided that the following conditions are
|
10
|
-
met:
|
11
|
-
|
12
|
-
* Redistributions of source code must retain the above copyright
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
14
|
-
* Redistributions in binary form must reproduce the above
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
16
|
-
in the documentation and/or other materials provided with the
|
17
|
-
distribution.
|
18
|
-
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
You can contact the author at :
|
32
|
-
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
33
|
-
*/
|
34
|
-
|
35
|
-
/* Notice extracted from xxHash homepage :
|
36
|
-
|
37
|
-
xxHash is an extremely fast Hash algorithm, running at RAM speed limits.
|
38
|
-
It also successfully passes all tests from the SMHasher suite.
|
39
|
-
|
40
|
-
Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz)
|
41
|
-
|
42
|
-
Name Speed Q.Score Author
|
43
|
-
xxHash 5.4 GB/s 10
|
44
|
-
CrapWow 3.2 GB/s 2 Andrew
|
45
|
-
MumurHash 3a 2.7 GB/s 10 Austin Appleby
|
46
|
-
SpookyHash 2.0 GB/s 10 Bob Jenkins
|
47
|
-
SBox 1.4 GB/s 9 Bret Mulvey
|
48
|
-
Lookup3 1.2 GB/s 9 Bob Jenkins
|
49
|
-
SuperFastHash 1.2 GB/s 1 Paul Hsieh
|
50
|
-
CityHash64 1.05 GB/s 10 Pike & Alakuijala
|
51
|
-
FNV 0.55 GB/s 5 Fowler, Noll, Vo
|
52
|
-
CRC32 0.43 GB/s 9
|
53
|
-
MD5-32 0.33 GB/s 10 Ronald L. Rivest
|
54
|
-
SHA1-32 0.28 GB/s 10
|
55
|
-
|
56
|
-
Q.Score is a measure of quality of the hash function.
|
57
|
-
It depends on successfully passing SMHasher test set.
|
58
|
-
10 is a perfect score.
|
59
|
-
|
60
|
-
A 64-bits version, named XXH64, is available since r35.
|
61
|
-
It offers much better speed, but for 64-bits applications only.
|
62
|
-
Name Speed on 64 bits Speed on 32 bits
|
63
|
-
XXH64 13.8 GB/s 1.9 GB/s
|
64
|
-
XXH32 6.8 GB/s 6.0 GB/s
|
65
|
-
*/
|
66
|
-
|
67
|
-
#if defined (__cplusplus)
|
68
|
-
extern "C" {
|
69
|
-
#endif
|
70
|
-
|
71
|
-
#ifndef XXHASH_H_5627135585666179
|
72
|
-
#define XXHASH_H_5627135585666179 1
|
73
|
-
|
74
|
-
|
75
|
-
/* ****************************
|
76
|
-
* Definitions
|
77
|
-
******************************/
|
78
|
-
#include <stddef.h> /* size_t */
|
79
|
-
typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
|
80
|
-
|
81
|
-
|
82
|
-
/* ****************************
|
83
|
-
* API modifier
|
84
|
-
******************************/
|
85
|
-
/** XXH_PRIVATE_API
|
86
|
-
* This is useful if you want to include xxhash functions in `static` mode
|
87
|
-
* in order to inline them, and remove their symbol from the public list.
|
88
|
-
* Methodology :
|
89
|
-
* #define XXH_PRIVATE_API
|
90
|
-
* #include "xxhash.h"
|
91
|
-
* `xxhash.c` is automatically included.
|
92
|
-
* It's not useful to compile and link it as a separate module anymore.
|
93
|
-
*/
|
94
|
-
#ifdef XXH_PRIVATE_API
|
95
|
-
# ifndef XXH_STATIC_LINKING_ONLY
|
96
|
-
# define XXH_STATIC_LINKING_ONLY
|
97
|
-
# endif
|
98
|
-
# if defined(__GNUC__)
|
99
|
-
# define XXH_PUBLIC_API static __inline __attribute__((unused))
|
100
|
-
# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
101
|
-
# define XXH_PUBLIC_API static inline
|
102
|
-
# elif defined(_MSC_VER)
|
103
|
-
# define XXH_PUBLIC_API static __inline
|
104
|
-
# else
|
105
|
-
# define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
106
|
-
# endif
|
107
|
-
#else
|
108
|
-
# define XXH_PUBLIC_API /* do nothing */
|
109
|
-
#endif /* XXH_PRIVATE_API */
|
110
|
-
|
111
|
-
/*!XXH_NAMESPACE, aka Namespace Emulation :
|
112
|
-
|
113
|
-
If you want to include _and expose_ xxHash functions from within your own library,
|
114
|
-
but also want to avoid symbol collisions with another library which also includes xxHash,
|
115
|
-
|
116
|
-
you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
|
117
|
-
with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid numeric values).
|
118
|
-
|
119
|
-
Note that no change is required within the calling program as long as it includes `xxhash.h` :
|
120
|
-
regular symbol name will be automatically translated by this header.
|
121
|
-
*/
|
122
|
-
#ifdef XXH_NAMESPACE
|
123
|
-
# define XXH_CAT(A,B) A##B
|
124
|
-
# define XXH_NAME2(A,B) XXH_CAT(A,B)
|
125
|
-
# define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
|
126
|
-
# define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64)
|
127
|
-
# define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber)
|
128
|
-
# define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState)
|
129
|
-
# define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState)
|
130
|
-
# define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState)
|
131
|
-
# define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState)
|
132
|
-
# define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
|
133
|
-
# define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset)
|
134
|
-
# define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
|
135
|
-
# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
|
136
|
-
# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
|
137
|
-
# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
|
138
|
-
# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState)
|
139
|
-
# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState)
|
140
|
-
# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash)
|
141
|
-
# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash)
|
142
|
-
# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical)
|
143
|
-
# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical)
|
144
|
-
#endif
|
145
|
-
|
146
|
-
|
147
|
-
/* *************************************
|
148
|
-
* Version
|
149
|
-
***************************************/
|
150
|
-
#define XXH_VERSION_MAJOR 0
|
151
|
-
#define XXH_VERSION_MINOR 6
|
152
|
-
#define XXH_VERSION_RELEASE 2
|
153
|
-
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
|
154
|
-
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
|
155
|
-
|
156
|
-
|
157
|
-
/* ****************************
|
158
|
-
* Simple Hash Functions
|
159
|
-
******************************/
|
160
|
-
typedef unsigned int XXH32_hash_t;
|
161
|
-
typedef unsigned long long XXH64_hash_t;
|
162
|
-
|
163
|
-
XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed);
|
164
|
-
XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed);
|
165
|
-
|
166
|
-
/*!
|
167
|
-
XXH32() :
|
168
|
-
Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input".
|
169
|
-
The memory between input & input+length must be valid (allocated and read-accessible).
|
170
|
-
"seed" can be used to alter the result predictably.
|
171
|
-
Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s
|
172
|
-
XXH64() :
|
173
|
-
Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
|
174
|
-
"seed" can be used to alter the result predictably.
|
175
|
-
This function runs 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
|
176
|
-
*/
|
177
|
-
|
178
|
-
|
179
|
-
/* ****************************
|
180
|
-
* Streaming Hash Functions
|
181
|
-
******************************/
|
182
|
-
typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
|
183
|
-
typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
|
184
|
-
|
185
|
-
/*! State allocation, compatible with dynamic libraries */
|
186
|
-
|
187
|
-
XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void);
|
188
|
-
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr);
|
189
|
-
|
190
|
-
XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void);
|
191
|
-
XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr);
|
192
|
-
|
193
|
-
|
194
|
-
/* hash streaming */
|
195
|
-
|
196
|
-
XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed);
|
197
|
-
XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length);
|
198
|
-
XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
|
199
|
-
|
200
|
-
XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed);
|
201
|
-
XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
|
202
|
-
XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
|
203
|
-
|
204
|
-
/*
|
205
|
-
These functions generate the xxHash of an input provided in multiple segments.
|
206
|
-
Note that, for small input, they are slower than single-call functions, due to state management.
|
207
|
-
For small input, prefer `XXH32()` and `XXH64()` .
|
208
|
-
|
209
|
-
XXH state must first be allocated, using XXH*_createState() .
|
210
|
-
|
211
|
-
Start a new hash by initializing state with a seed, using XXH*_reset().
|
212
|
-
|
213
|
-
Then, feed the hash state by calling XXH*_update() as many times as necessary.
|
214
|
-
Obviously, input must be allocated and read accessible.
|
215
|
-
The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
|
216
|
-
|
217
|
-
Finally, a hash value can be produced anytime, by using XXH*_digest().
|
218
|
-
This function returns the nn-bits hash as an int or long long.
|
219
|
-
|
220
|
-
It's still possible to continue inserting input into the hash state after a digest,
|
221
|
-
and generate some new hashes later on, by calling again XXH*_digest().
|
222
|
-
|
223
|
-
When done, free XXH state space if it was allocated dynamically.
|
224
|
-
*/
|
225
|
-
|
226
|
-
|
227
|
-
/* **************************
|
228
|
-
* Utils
|
229
|
-
****************************/
|
230
|
-
#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* ! C99 */
|
231
|
-
# define restrict /* disable restrict */
|
232
|
-
#endif
|
233
|
-
|
234
|
-
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dst_state, const XXH32_state_t* restrict src_state);
|
235
|
-
XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH64_state_t* restrict src_state);
|
236
|
-
|
237
|
-
|
238
|
-
/* **************************
|
239
|
-
* Canonical representation
|
240
|
-
****************************/
|
241
|
-
/* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
|
242
|
-
* The canonical representation uses human-readable write convention, aka big-endian (large digits first).
|
243
|
-
* These functions allow transformation of hash result into and from its canonical format.
|
244
|
-
* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
|
245
|
-
*/
|
246
|
-
typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
|
247
|
-
typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
|
248
|
-
|
249
|
-
XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash);
|
250
|
-
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash);
|
251
|
-
|
252
|
-
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
|
253
|
-
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
|
254
|
-
|
255
|
-
#endif /* XXHASH_H_5627135585666179 */
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
/* ================================================================================================
|
260
|
-
This section contains definitions which are not guaranteed to remain stable.
|
261
|
-
They may change in future versions, becoming incompatible with a different version of the library.
|
262
|
-
They shall only be used with static linking.
|
263
|
-
Never use these definitions in association with dynamic linking !
|
264
|
-
=================================================================================================== */
|
265
|
-
#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345)
|
266
|
-
#define XXH_STATIC_H_3543687687345
|
267
|
-
|
268
|
-
/* These definitions are only meant to allow allocation of XXH state
|
269
|
-
statically, on stack, or in a struct for example.
|
270
|
-
Do not use members directly. */
|
271
|
-
|
272
|
-
struct XXH32_state_s {
|
273
|
-
unsigned total_len_32;
|
274
|
-
unsigned large_len;
|
275
|
-
unsigned v1;
|
276
|
-
unsigned v2;
|
277
|
-
unsigned v3;
|
278
|
-
unsigned v4;
|
279
|
-
unsigned mem32[4]; /* buffer defined as U32 for alignment */
|
280
|
-
unsigned memsize;
|
281
|
-
unsigned reserved; /* never read nor write, will be removed in a future version */
|
282
|
-
}; /* typedef'd to XXH32_state_t */
|
283
|
-
|
284
|
-
struct XXH64_state_s {
|
285
|
-
unsigned long long total_len;
|
286
|
-
unsigned long long v1;
|
287
|
-
unsigned long long v2;
|
288
|
-
unsigned long long v3;
|
289
|
-
unsigned long long v4;
|
290
|
-
unsigned long long mem64[4]; /* buffer defined as U64 for alignment */
|
291
|
-
unsigned memsize;
|
292
|
-
unsigned reserved[2]; /* never read nor write, will be removed in a future version */
|
293
|
-
}; /* typedef'd to XXH64_state_t */
|
294
|
-
|
295
|
-
|
296
|
-
# ifdef XXH_PRIVATE_API
|
297
|
-
# include "xxhash.c" /* include xxhash functions as `static`, for inlining */
|
298
|
-
# endif
|
299
|
-
|
300
|
-
#endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */
|
301
|
-
|
302
|
-
|
303
|
-
#if defined (__cplusplus)
|
304
|
-
}
|
305
|
-
#endif
|
@@ -1,350 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under both the BSD-style license (found in the
|
6
|
-
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
-
* in the COPYING file in the root directory of this source tree).
|
8
|
-
* You may select, at your option, one of the above-listed licenses.
|
9
|
-
*/
|
10
|
-
|
11
|
-
#ifndef ZSTD_CCOMMON_H_MODULE
|
12
|
-
#define ZSTD_CCOMMON_H_MODULE
|
13
|
-
|
14
|
-
/* this module contains definitions which must be identical
|
15
|
-
* across compression, decompression and dictBuilder.
|
16
|
-
* It also contains a few functions useful to at least 2 of them
|
17
|
-
* and which benefit from being inlined */
|
18
|
-
|
19
|
-
/*-*************************************
|
20
|
-
* Dependencies
|
21
|
-
***************************************/
|
22
|
-
#include "compiler.h"
|
23
|
-
#include "mem.h"
|
24
|
-
#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
|
25
|
-
#include "error_private.h"
|
26
|
-
#define ZSTD_STATIC_LINKING_ONLY
|
27
|
-
#include "zstd.h"
|
28
|
-
#define FSE_STATIC_LINKING_ONLY
|
29
|
-
#include "fse.h"
|
30
|
-
#define HUF_STATIC_LINKING_ONLY
|
31
|
-
#include "huf.h"
|
32
|
-
#ifndef XXH_STATIC_LINKING_ONLY
|
33
|
-
# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
34
|
-
#endif
|
35
|
-
#include "xxhash.h" /* XXH_reset, update, digest */
|
36
|
-
|
37
|
-
#if defined (__cplusplus)
|
38
|
-
extern "C" {
|
39
|
-
#endif
|
40
|
-
|
41
|
-
/* ---- static assert (debug) --- */
|
42
|
-
#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
|
43
|
-
#define ZSTD_isError ERR_isError /* for inlining */
|
44
|
-
#define FSE_isError ERR_isError
|
45
|
-
#define HUF_isError ERR_isError
|
46
|
-
|
47
|
-
|
48
|
-
/*-*************************************
|
49
|
-
* shared macros
|
50
|
-
***************************************/
|
51
|
-
#undef MIN
|
52
|
-
#undef MAX
|
53
|
-
#define MIN(a,b) ((a)<(b) ? (a) : (b))
|
54
|
-
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Return the specified error if the condition evaluates to true.
|
58
|
-
*
|
59
|
-
* In debug modes, prints additional information.
|
60
|
-
* In order to do that (particularly, printing the conditional that failed),
|
61
|
-
* this can't just wrap RETURN_ERROR().
|
62
|
-
*/
|
63
|
-
#define RETURN_ERROR_IF(cond, err, ...) \
|
64
|
-
if (cond) { \
|
65
|
-
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
|
66
|
-
RAWLOG(3, ": " __VA_ARGS__); \
|
67
|
-
RAWLOG(3, "\n"); \
|
68
|
-
return ERROR(err); \
|
69
|
-
}
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Unconditionally return the specified error.
|
73
|
-
*
|
74
|
-
* In debug modes, prints additional information.
|
75
|
-
*/
|
76
|
-
#define RETURN_ERROR(err, ...) \
|
77
|
-
do { \
|
78
|
-
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \
|
79
|
-
RAWLOG(3, ": " __VA_ARGS__); \
|
80
|
-
RAWLOG(3, "\n"); \
|
81
|
-
return ERROR(err); \
|
82
|
-
} while(0);
|
83
|
-
|
84
|
-
/**
|
85
|
-
* If the provided expression evaluates to an error code, returns that error code.
|
86
|
-
*
|
87
|
-
* In debug modes, prints additional information.
|
88
|
-
*/
|
89
|
-
#define FORWARD_IF_ERROR(err, ...) \
|
90
|
-
do { \
|
91
|
-
size_t const err_code = (err); \
|
92
|
-
if (ERR_isError(err_code)) { \
|
93
|
-
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \
|
94
|
-
RAWLOG(3, ": " __VA_ARGS__); \
|
95
|
-
RAWLOG(3, "\n"); \
|
96
|
-
return err_code; \
|
97
|
-
} \
|
98
|
-
} while(0);
|
99
|
-
|
100
|
-
|
101
|
-
/*-*************************************
|
102
|
-
* Common constants
|
103
|
-
***************************************/
|
104
|
-
#define ZSTD_OPT_NUM (1<<12)
|
105
|
-
|
106
|
-
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
107
|
-
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
108
|
-
static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
109
|
-
|
110
|
-
#define KB *(1 <<10)
|
111
|
-
#define MB *(1 <<20)
|
112
|
-
#define GB *(1U<<30)
|
113
|
-
|
114
|
-
#define BIT7 128
|
115
|
-
#define BIT6 64
|
116
|
-
#define BIT5 32
|
117
|
-
#define BIT4 16
|
118
|
-
#define BIT1 2
|
119
|
-
#define BIT0 1
|
120
|
-
|
121
|
-
#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
|
122
|
-
static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
|
123
|
-
static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
|
124
|
-
|
125
|
-
#define ZSTD_FRAMEIDSIZE 4 /* magic number size */
|
126
|
-
|
127
|
-
#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
|
128
|
-
static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
|
129
|
-
typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
|
130
|
-
|
131
|
-
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
132
|
-
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
|
133
|
-
|
134
|
-
#define HufLog 12
|
135
|
-
typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
|
136
|
-
|
137
|
-
#define LONGNBSEQ 0x7F00
|
138
|
-
|
139
|
-
#define MINMATCH 3
|
140
|
-
|
141
|
-
#define Litbits 8
|
142
|
-
#define MaxLit ((1<<Litbits) - 1)
|
143
|
-
#define MaxML 52
|
144
|
-
#define MaxLL 35
|
145
|
-
#define DefaultMaxOff 28
|
146
|
-
#define MaxOff 31
|
147
|
-
#define MaxSeq MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */
|
148
|
-
#define MLFSELog 9
|
149
|
-
#define LLFSELog 9
|
150
|
-
#define OffFSELog 8
|
151
|
-
#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
|
152
|
-
|
153
|
-
static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
154
|
-
0, 0, 0, 0, 0, 0, 0, 0,
|
155
|
-
1, 1, 1, 1, 2, 2, 3, 3,
|
156
|
-
4, 6, 7, 8, 9,10,11,12,
|
157
|
-
13,14,15,16 };
|
158
|
-
static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
|
159
|
-
2, 2, 2, 2, 2, 1, 1, 1,
|
160
|
-
2, 2, 2, 2, 2, 2, 2, 2,
|
161
|
-
2, 3, 2, 1, 1, 1, 1, 1,
|
162
|
-
-1,-1,-1,-1 };
|
163
|
-
#define LL_DEFAULTNORMLOG 6 /* for static allocation */
|
164
|
-
static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
165
|
-
|
166
|
-
static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
167
|
-
0, 0, 0, 0, 0, 0, 0, 0,
|
168
|
-
0, 0, 0, 0, 0, 0, 0, 0,
|
169
|
-
0, 0, 0, 0, 0, 0, 0, 0,
|
170
|
-
1, 1, 1, 1, 2, 2, 3, 3,
|
171
|
-
4, 4, 5, 7, 8, 9,10,11,
|
172
|
-
12,13,14,15,16 };
|
173
|
-
static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
|
174
|
-
2, 1, 1, 1, 1, 1, 1, 1,
|
175
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
176
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
177
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
178
|
-
1, 1, 1, 1, 1, 1,-1,-1,
|
179
|
-
-1,-1,-1,-1,-1 };
|
180
|
-
#define ML_DEFAULTNORMLOG 6 /* for static allocation */
|
181
|
-
static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
182
|
-
|
183
|
-
static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
|
184
|
-
2, 1, 1, 1, 1, 1, 1, 1,
|
185
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
186
|
-
-1,-1,-1,-1,-1 };
|
187
|
-
#define OF_DEFAULTNORMLOG 5 /* for static allocation */
|
188
|
-
static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
189
|
-
|
190
|
-
|
191
|
-
/*-*******************************************
|
192
|
-
* Shared functions to include for inlining
|
193
|
-
*********************************************/
|
194
|
-
static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
|
195
|
-
|
196
|
-
#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
|
197
|
-
static void ZSTD_copy16(void* dst, const void* src) { memcpy(dst, src, 16); }
|
198
|
-
#define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
|
199
|
-
|
200
|
-
#define WILDCOPY_OVERLENGTH 32
|
201
|
-
#define WILDCOPY_VECLEN 16
|
202
|
-
|
203
|
-
typedef enum {
|
204
|
-
ZSTD_no_overlap,
|
205
|
-
ZSTD_overlap_src_before_dst
|
206
|
-
/* ZSTD_overlap_dst_before_src, */
|
207
|
-
} ZSTD_overlap_e;
|
208
|
-
|
209
|
-
/*! ZSTD_wildcopy() :
|
210
|
-
* Custom version of memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
|
211
|
-
* @param ovtype controls the overlap detection
|
212
|
-
* - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
|
213
|
-
* - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
|
214
|
-
* The src buffer must be before the dst buffer.
|
215
|
-
*/
|
216
|
-
MEM_STATIC FORCE_INLINE_ATTR DONT_VECTORIZE
|
217
|
-
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
|
218
|
-
{
|
219
|
-
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
220
|
-
const BYTE* ip = (const BYTE*)src;
|
221
|
-
BYTE* op = (BYTE*)dst;
|
222
|
-
BYTE* const oend = op + length;
|
223
|
-
|
224
|
-
assert(diff >= 8 || (ovtype == ZSTD_no_overlap && diff <= -WILDCOPY_VECLEN));
|
225
|
-
|
226
|
-
if (ovtype == ZSTD_overlap_src_before_dst && diff < WILDCOPY_VECLEN) {
|
227
|
-
/* Handle short offset copies. */
|
228
|
-
do {
|
229
|
-
COPY8(op, ip)
|
230
|
-
} while (op < oend);
|
231
|
-
} else {
|
232
|
-
assert(diff >= WILDCOPY_VECLEN || diff <= -WILDCOPY_VECLEN);
|
233
|
-
/* Separate out the first two COPY16() calls because the copy length is
|
234
|
-
* almost certain to be short, so the branches have different
|
235
|
-
* probabilities.
|
236
|
-
* On gcc-9 unrolling once is +1.6%, twice is +2%, thrice is +1.8%.
|
237
|
-
* On clang-8 unrolling once is +1.4%, twice is +3.3%, thrice is +3%.
|
238
|
-
*/
|
239
|
-
COPY16(op, ip);
|
240
|
-
COPY16(op, ip);
|
241
|
-
if (op >= oend) return;
|
242
|
-
do {
|
243
|
-
COPY16(op, ip);
|
244
|
-
COPY16(op, ip);
|
245
|
-
}
|
246
|
-
while (op < oend);
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
|
251
|
-
/*-*******************************************
|
252
|
-
* Private declarations
|
253
|
-
*********************************************/
|
254
|
-
typedef struct seqDef_s {
|
255
|
-
U32 offset;
|
256
|
-
U16 litLength;
|
257
|
-
U16 matchLength;
|
258
|
-
} seqDef;
|
259
|
-
|
260
|
-
typedef struct {
|
261
|
-
seqDef* sequencesStart;
|
262
|
-
seqDef* sequences;
|
263
|
-
BYTE* litStart;
|
264
|
-
BYTE* lit;
|
265
|
-
BYTE* llCode;
|
266
|
-
BYTE* mlCode;
|
267
|
-
BYTE* ofCode;
|
268
|
-
size_t maxNbSeq;
|
269
|
-
size_t maxNbLit;
|
270
|
-
U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
|
271
|
-
U32 longLengthPos;
|
272
|
-
} seqStore_t;
|
273
|
-
|
274
|
-
/**
|
275
|
-
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
276
|
-
* Note: before using `compressedSize`, check for errors using ZSTD_isError().
|
277
|
-
* similarly, before using `decompressedBound`, check for errors using:
|
278
|
-
* `decompressedBound != ZSTD_CONTENTSIZE_ERROR`
|
279
|
-
*/
|
280
|
-
typedef struct {
|
281
|
-
size_t compressedSize;
|
282
|
-
unsigned long long decompressedBound;
|
283
|
-
} ZSTD_frameSizeInfo; /* decompress & legacy */
|
284
|
-
|
285
|
-
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
286
|
-
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
287
|
-
|
288
|
-
/* custom memory allocation functions */
|
289
|
-
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
|
290
|
-
void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
|
291
|
-
void ZSTD_free(void* ptr, ZSTD_customMem customMem);
|
292
|
-
|
293
|
-
|
294
|
-
MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
295
|
-
{
|
296
|
-
assert(val != 0);
|
297
|
-
{
|
298
|
-
# if defined(_MSC_VER) /* Visual */
|
299
|
-
unsigned long r=0;
|
300
|
-
_BitScanReverse(&r, val);
|
301
|
-
return (unsigned)r;
|
302
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
|
303
|
-
return __builtin_clz (val) ^ 31;
|
304
|
-
# elif defined(__ICCARM__) /* IAR Intrinsic */
|
305
|
-
return 31 - __CLZ(val);
|
306
|
-
# else /* Software version */
|
307
|
-
static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
|
308
|
-
U32 v = val;
|
309
|
-
v |= v >> 1;
|
310
|
-
v |= v >> 2;
|
311
|
-
v |= v >> 4;
|
312
|
-
v |= v >> 8;
|
313
|
-
v |= v >> 16;
|
314
|
-
return DeBruijnClz[(v * 0x07C4ACDDU) >> 27];
|
315
|
-
# endif
|
316
|
-
}
|
317
|
-
}
|
318
|
-
|
319
|
-
|
320
|
-
/* ZSTD_invalidateRepCodes() :
|
321
|
-
* ensures next compression will not use repcodes from previous block.
|
322
|
-
* Note : only works with regular variant;
|
323
|
-
* do not use with extDict variant ! */
|
324
|
-
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */
|
325
|
-
|
326
|
-
|
327
|
-
typedef struct {
|
328
|
-
blockType_e blockType;
|
329
|
-
U32 lastBlock;
|
330
|
-
U32 origSize;
|
331
|
-
} blockProperties_t; /* declared here for decompress and fullbench */
|
332
|
-
|
333
|
-
/*! ZSTD_getcBlockSize() :
|
334
|
-
* Provides the size of compressed block from block header `src` */
|
335
|
-
/* Used by: decompress, fullbench (does not get its definition from here) */
|
336
|
-
size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
|
337
|
-
blockProperties_t* bpPtr);
|
338
|
-
|
339
|
-
/*! ZSTD_decodeSeqHeaders() :
|
340
|
-
* decode sequence header from src */
|
341
|
-
/* Used by: decompress, fullbench (does not get its definition from here) */
|
342
|
-
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
343
|
-
const void* src, size_t srcSize);
|
344
|
-
|
345
|
-
|
346
|
-
#if defined (__cplusplus)
|
347
|
-
}
|
348
|
-
#endif
|
349
|
-
|
350
|
-
#endif /* ZSTD_CCOMMON_H_MODULE */
|