zstdlib 0.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +9 -0
  3. data/Gemfile +3 -0
  4. data/README.md +96 -0
  5. data/Rakefile +29 -0
  6. data/ext/zstdlib/extconf.rb +53 -0
  7. data/ext/zstdlib/ruby/zlib-2.2/zlib.c +4659 -0
  8. data/ext/zstdlib/ruby/zlib-2.3/zlib.c +4686 -0
  9. data/ext/zstdlib/ruby/zlib-2.4/zlib.c +4843 -0
  10. data/ext/zstdlib/ruby/zlib-2.5/zlib.c +4848 -0
  11. data/ext/zstdlib/ruby/zlib-2.6/zlib.c +4890 -0
  12. data/ext/zstdlib/zlib-1.2.11/adler32.c +186 -0
  13. data/ext/zstdlib/zlib-1.2.11/compress.c +86 -0
  14. data/ext/zstdlib/zlib-1.2.11/crc32.c +442 -0
  15. data/ext/zstdlib/zlib-1.2.11/crc32.h +441 -0
  16. data/ext/zstdlib/zlib-1.2.11/deflate.c +2163 -0
  17. data/ext/zstdlib/zlib-1.2.11/deflate.h +349 -0
  18. data/ext/zstdlib/zlib-1.2.11/gzclose.c +25 -0
  19. data/ext/zstdlib/zlib-1.2.11/gzguts.h +218 -0
  20. data/ext/zstdlib/zlib-1.2.11/gzlib.c +637 -0
  21. data/ext/zstdlib/zlib-1.2.11/gzread.c +654 -0
  22. data/ext/zstdlib/zlib-1.2.11/gzwrite.c +665 -0
  23. data/ext/zstdlib/zlib-1.2.11/infback.c +640 -0
  24. data/ext/zstdlib/zlib-1.2.11/inffast.c +323 -0
  25. data/ext/zstdlib/zlib-1.2.11/inffast.h +11 -0
  26. data/ext/zstdlib/zlib-1.2.11/inffixed.h +94 -0
  27. data/ext/zstdlib/zlib-1.2.11/inflate.c +1561 -0
  28. data/ext/zstdlib/zlib-1.2.11/inflate.h +125 -0
  29. data/ext/zstdlib/zlib-1.2.11/inftrees.c +304 -0
  30. data/ext/zstdlib/zlib-1.2.11/inftrees.h +62 -0
  31. data/ext/zstdlib/zlib-1.2.11/trees.c +1203 -0
  32. data/ext/zstdlib/zlib-1.2.11/trees.h +128 -0
  33. data/ext/zstdlib/zlib-1.2.11/uncompr.c +93 -0
  34. data/ext/zstdlib/zlib-1.2.11/zconf.h +534 -0
  35. data/ext/zstdlib/zlib-1.2.11/zlib.h +1912 -0
  36. data/ext/zstdlib/zlib-1.2.11/zutil.c +325 -0
  37. data/ext/zstdlib/zlib-1.2.11/zutil.h +271 -0
  38. data/ext/zstdlib/zlib.mk +14 -0
  39. data/ext/zstdlib/zlibwrapper/zlibwrapper.c +14 -0
  40. data/ext/zstdlib/zlibwrapper.mk +14 -0
  41. data/ext/zstdlib/zstd-1.3.8/lib/common/bitstream.h +455 -0
  42. data/ext/zstdlib/zstd-1.3.8/lib/common/compiler.h +140 -0
  43. data/ext/zstdlib/zstd-1.3.8/lib/common/cpu.h +215 -0
  44. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.c +44 -0
  45. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.h +134 -0
  46. data/ext/zstdlib/zstd-1.3.8/lib/common/entropy_common.c +236 -0
  47. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.c +54 -0
  48. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.h +76 -0
  49. data/ext/zstdlib/zstd-1.3.8/lib/common/fse.h +708 -0
  50. data/ext/zstdlib/zstd-1.3.8/lib/common/fse_decompress.c +309 -0
  51. data/ext/zstdlib/zstd-1.3.8/lib/common/huf.h +358 -0
  52. data/ext/zstdlib/zstd-1.3.8/lib/common/mem.h +380 -0
  53. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.c +340 -0
  54. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.h +84 -0
  55. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.c +75 -0
  56. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.h +123 -0
  57. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.c +876 -0
  58. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.h +305 -0
  59. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_common.c +83 -0
  60. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_errors.h +93 -0
  61. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_internal.h +266 -0
  62. data/ext/zstdlib/zstd-1.3.8/lib/compress/fse_compress.c +721 -0
  63. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.c +203 -0
  64. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.h +95 -0
  65. data/ext/zstdlib/zstd-1.3.8/lib/compress/huf_compress.c +798 -0
  66. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress.c +4290 -0
  67. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress_internal.h +860 -0
  68. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.c +499 -0
  69. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.h +38 -0
  70. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.c +391 -0
  71. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.h +37 -0
  72. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.c +1106 -0
  73. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.h +67 -0
  74. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.c +597 -0
  75. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.h +105 -0
  76. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.c +1217 -0
  77. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.h +56 -0
  78. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.c +2107 -0
  79. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.h +174 -0
  80. data/ext/zstdlib/zstd-1.3.8/lib/decompress/huf_decompress.c +1232 -0
  81. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.c +240 -0
  82. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.h +44 -0
  83. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress.c +1672 -0
  84. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.c +1307 -0
  85. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.h +59 -0
  86. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_internal.h +168 -0
  87. data/ext/zstdlib/zstd-1.3.8/lib/zstd.h +1766 -0
  88. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzclose.c +28 -0
  89. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzcompatibility.h +68 -0
  90. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzguts.h +227 -0
  91. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzlib.c +640 -0
  92. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzread.c +670 -0
  93. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzwrite.c +671 -0
  94. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.c +1105 -0
  95. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.h +88 -0
  96. data/ext/zstdlib/zstd.mk +14 -0
  97. data/lib/2.2/zstdlib.so +0 -0
  98. data/lib/2.3/zstdlib.so +0 -0
  99. data/lib/2.4/zstdlib.so +0 -0
  100. data/lib/2.5/zstdlib.so +0 -0
  101. data/lib/2.6/zstdlib.so +0 -0
  102. data/lib/zstdlib.rb +6 -0
  103. data/test/zstdlib_test.rb +21 -0
  104. metadata +205 -0
@@ -0,0 +1,59 @@
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
+
12
+ #ifndef ZSTD_DEC_BLOCK_H
13
+ #define ZSTD_DEC_BLOCK_H
14
+
15
+ /*-*******************************************************
16
+ * Dependencies
17
+ *********************************************************/
18
+ #include <stddef.h> /* size_t */
19
+ #include "zstd.h" /* DCtx, and some public functions */
20
+ #include "zstd_internal.h" /* blockProperties_t, and some public functions */
21
+ #include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */
22
+
23
+
24
+ /* === Prototypes === */
25
+
26
+ /* note: prototypes already published within `zstd.h` :
27
+ * ZSTD_decompressBlock()
28
+ */
29
+
30
+ /* note: prototypes already published within `zstd_internal.h` :
31
+ * ZSTD_getcBlockSize()
32
+ * ZSTD_decodeSeqHeaders()
33
+ */
34
+
35
+
36
+ /* ZSTD_decompressBlock_internal() :
37
+ * decompress block, starting at `src`,
38
+ * into destination buffer `dst`.
39
+ * @return : decompressed block size,
40
+ * or an error code (which can be tested using ZSTD_isError())
41
+ */
42
+ size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
43
+ void* dst, size_t dstCapacity,
44
+ const void* src, size_t srcSize, const int frame);
45
+
46
+ /* ZSTD_buildFSETable() :
47
+ * generate FSE decoding table for one symbol (ll, ml or off)
48
+ * this function must be called with valid parameters only
49
+ * (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
50
+ * in which case it cannot fail.
51
+ * Internal use only.
52
+ */
53
+ void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
54
+ const short* normalizedCounter, unsigned maxSymbolValue,
55
+ const U32* baseValue, const U32* nbAdditionalBits,
56
+ unsigned tableLog);
57
+
58
+
59
+ #endif /* ZSTD_DEC_BLOCK_H */
@@ -0,0 +1,168 @@
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
+
12
+ /* zstd_decompress_internal:
13
+ * objects and definitions shared within lib/decompress modules */
14
+
15
+ #ifndef ZSTD_DECOMPRESS_INTERNAL_H
16
+ #define ZSTD_DECOMPRESS_INTERNAL_H
17
+
18
+
19
+ /*-*******************************************************
20
+ * Dependencies
21
+ *********************************************************/
22
+ #include "mem.h" /* BYTE, U16, U32 */
23
+ #include "zstd_internal.h" /* ZSTD_seqSymbol */
24
+
25
+
26
+
27
+ /*-*******************************************************
28
+ * Constants
29
+ *********************************************************/
30
+ static const U32 LL_base[MaxLL+1] = {
31
+ 0, 1, 2, 3, 4, 5, 6, 7,
32
+ 8, 9, 10, 11, 12, 13, 14, 15,
33
+ 16, 18, 20, 22, 24, 28, 32, 40,
34
+ 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
35
+ 0x2000, 0x4000, 0x8000, 0x10000 };
36
+
37
+ static const U32 OF_base[MaxOff+1] = {
38
+ 0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D,
39
+ 0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD,
40
+ 0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD,
41
+ 0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD };
42
+
43
+ static const U32 OF_bits[MaxOff+1] = {
44
+ 0, 1, 2, 3, 4, 5, 6, 7,
45
+ 8, 9, 10, 11, 12, 13, 14, 15,
46
+ 16, 17, 18, 19, 20, 21, 22, 23,
47
+ 24, 25, 26, 27, 28, 29, 30, 31 };
48
+
49
+ static const U32 ML_base[MaxML+1] = {
50
+ 3, 4, 5, 6, 7, 8, 9, 10,
51
+ 11, 12, 13, 14, 15, 16, 17, 18,
52
+ 19, 20, 21, 22, 23, 24, 25, 26,
53
+ 27, 28, 29, 30, 31, 32, 33, 34,
54
+ 35, 37, 39, 41, 43, 47, 51, 59,
55
+ 67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803,
56
+ 0x1003, 0x2003, 0x4003, 0x8003, 0x10003 };
57
+
58
+
59
+ /*-*******************************************************
60
+ * Decompression types
61
+ *********************************************************/
62
+ typedef struct {
63
+ U32 fastMode;
64
+ U32 tableLog;
65
+ } ZSTD_seqSymbol_header;
66
+
67
+ typedef struct {
68
+ U16 nextState;
69
+ BYTE nbAdditionalBits;
70
+ BYTE nbBits;
71
+ U32 baseValue;
72
+ } ZSTD_seqSymbol;
73
+
74
+ #define SEQSYMBOL_TABLE_SIZE(log) (1 + (1 << (log)))
75
+
76
+ typedef struct {
77
+ ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */
78
+ ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */
79
+ ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */
80
+ HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */
81
+ U32 rep[ZSTD_REP_NUM];
82
+ } ZSTD_entropyDTables_t;
83
+
84
+ typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
85
+ ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock,
86
+ ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
87
+ ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
88
+
89
+ typedef enum { zdss_init=0, zdss_loadHeader,
90
+ zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
91
+
92
+ struct ZSTD_DCtx_s
93
+ {
94
+ const ZSTD_seqSymbol* LLTptr;
95
+ const ZSTD_seqSymbol* MLTptr;
96
+ const ZSTD_seqSymbol* OFTptr;
97
+ const HUF_DTable* HUFptr;
98
+ ZSTD_entropyDTables_t entropy;
99
+ U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */
100
+ const void* previousDstEnd; /* detect continuity */
101
+ const void* prefixStart; /* start of current segment */
102
+ const void* virtualStart; /* virtual start of previous segment if it was just before current one */
103
+ const void* dictEnd; /* end of previous segment */
104
+ size_t expected;
105
+ ZSTD_frameHeader fParams;
106
+ U64 decodedSize;
107
+ blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */
108
+ ZSTD_dStage stage;
109
+ U32 litEntropy;
110
+ U32 fseEntropy;
111
+ XXH64_state_t xxhState;
112
+ size_t headerSize;
113
+ ZSTD_format_e format;
114
+ const BYTE* litPtr;
115
+ ZSTD_customMem customMem;
116
+ size_t litSize;
117
+ size_t rleSize;
118
+ size_t staticSize;
119
+ int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
120
+
121
+ /* dictionary */
122
+ ZSTD_DDict* ddictLocal;
123
+ const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
124
+ U32 dictID;
125
+ int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
126
+
127
+ /* streaming */
128
+ ZSTD_dStreamStage streamStage;
129
+ char* inBuff;
130
+ size_t inBuffSize;
131
+ size_t inPos;
132
+ size_t maxWindowSize;
133
+ char* outBuff;
134
+ size_t outBuffSize;
135
+ size_t outStart;
136
+ size_t outEnd;
137
+ size_t lhSize;
138
+ void* legacyContext;
139
+ U32 previousLegacyVersion;
140
+ U32 legacyVersion;
141
+ U32 hostageByte;
142
+ int noForwardProgress;
143
+
144
+ /* workspace */
145
+ BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH];
146
+ BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
147
+ }; /* typedef'd to ZSTD_DCtx within "zstd.h" */
148
+
149
+
150
+ /*-*******************************************************
151
+ * Shared internal functions
152
+ *********************************************************/
153
+
154
+ /*! ZSTD_loadDEntropy() :
155
+ * dict : must point at beginning of a valid zstd dictionary.
156
+ * @return : size of entropy tables read */
157
+ size_t ZSTD_loadDEntropy(ZSTD_entropyDTables_t* entropy,
158
+ const void* const dict, size_t const dictSize);
159
+
160
+ /*! ZSTD_checkContinuity() :
161
+ * check if next `dst` follows previous position, where decompression ended.
162
+ * If yes, do nothing (continue on current segment).
163
+ * If not, classify previous segment as "external dictionary", and start a new segment.
164
+ * This function cannot fail. */
165
+ void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst);
166
+
167
+
168
+ #endif /* ZSTD_DECOMPRESS_INTERNAL_H */