zstd 1.1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +64 -0
  7. data/Rakefile +19 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/exe/zstd +3 -0
  11. data/ext/zstd/extconf.rb +20 -0
  12. data/ext/zstd/libzstd/.gitignore +2 -0
  13. data/ext/zstd/libzstd/LICENSE +1262 -0
  14. data/ext/zstd/libzstd/Makefile +133 -0
  15. data/ext/zstd/libzstd/PATENTS +1272 -0
  16. data/ext/zstd/libzstd/README.md +77 -0
  17. data/ext/zstd/libzstd/common/bitstream.h +414 -0
  18. data/ext/zstd/libzstd/common/entropy_common.c +227 -0
  19. data/ext/zstd/libzstd/common/error_private.c +43 -0
  20. data/ext/zstd/libzstd/common/error_private.h +76 -0
  21. data/ext/zstd/libzstd/common/fse.h +668 -0
  22. data/ext/zstd/libzstd/common/fse_decompress.c +329 -0
  23. data/ext/zstd/libzstd/common/huf.h +238 -0
  24. data/ext/zstd/libzstd/common/mem.h +372 -0
  25. data/ext/zstd/libzstd/common/xxhash.c +867 -0
  26. data/ext/zstd/libzstd/common/xxhash.h +309 -0
  27. data/ext/zstd/libzstd/common/zstd_common.c +77 -0
  28. data/ext/zstd/libzstd/common/zstd_errors.h +60 -0
  29. data/ext/zstd/libzstd/common/zstd_internal.h +270 -0
  30. data/ext/zstd/libzstd/compress/fse_compress.c +850 -0
  31. data/ext/zstd/libzstd/compress/huf_compress.c +609 -0
  32. data/ext/zstd/libzstd/compress/zstd_compress.c +3291 -0
  33. data/ext/zstd/libzstd/compress/zstd_opt.h +919 -0
  34. data/ext/zstd/libzstd/decompress/huf_decompress.c +885 -0
  35. data/ext/zstd/libzstd/decompress/zstd_decompress.c +2154 -0
  36. data/ext/zstd/libzstd/deprecated/zbuff.h +210 -0
  37. data/ext/zstd/libzstd/deprecated/zbuff_compress.c +145 -0
  38. data/ext/zstd/libzstd/deprecated/zbuff_decompress.c +74 -0
  39. data/ext/zstd/libzstd/dictBuilder/divsufsort.c +1913 -0
  40. data/ext/zstd/libzstd/dictBuilder/divsufsort.h +67 -0
  41. data/ext/zstd/libzstd/dictBuilder/zdict.c +1012 -0
  42. data/ext/zstd/libzstd/dictBuilder/zdict.h +111 -0
  43. data/ext/zstd/libzstd/dll/example/Makefile +47 -0
  44. data/ext/zstd/libzstd/dll/example/README.md +69 -0
  45. data/ext/zstd/libzstd/dll/example/build_package.bat +17 -0
  46. data/ext/zstd/libzstd/dll/example/fullbench-dll.sln +25 -0
  47. data/ext/zstd/libzstd/dll/example/fullbench-dll.vcxproj +179 -0
  48. data/ext/zstd/libzstd/dll/libzstd.def +86 -0
  49. data/ext/zstd/libzstd/legacy/zstd_legacy.h +259 -0
  50. data/ext/zstd/libzstd/legacy/zstd_v01.c +2095 -0
  51. data/ext/zstd/libzstd/legacy/zstd_v01.h +80 -0
  52. data/ext/zstd/libzstd/legacy/zstd_v02.c +3518 -0
  53. data/ext/zstd/libzstd/legacy/zstd_v02.h +79 -0
  54. data/ext/zstd/libzstd/legacy/zstd_v03.c +3159 -0
  55. data/ext/zstd/libzstd/legacy/zstd_v03.h +79 -0
  56. data/ext/zstd/libzstd/legacy/zstd_v04.c +3795 -0
  57. data/ext/zstd/libzstd/legacy/zstd_v04.h +128 -0
  58. data/ext/zstd/libzstd/legacy/zstd_v05.c +4056 -0
  59. data/ext/zstd/libzstd/legacy/zstd_v05.h +149 -0
  60. data/ext/zstd/libzstd/legacy/zstd_v06.c +4167 -0
  61. data/ext/zstd/libzstd/legacy/zstd_v06.h +159 -0
  62. data/ext/zstd/libzstd/legacy/zstd_v07.c +4540 -0
  63. data/ext/zstd/libzstd/legacy/zstd_v07.h +173 -0
  64. data/ext/zstd/libzstd/libzstd.pc.in +14 -0
  65. data/ext/zstd/libzstd/zstd.h +673 -0
  66. data/ext/zstd/zstd.c +185 -0
  67. data/ext/zstd/zstd.h +7 -0
  68. data/lib/zstd/version.rb +3 -0
  69. data/lib/zstd.rb +6 -0
  70. data/zstd.gemspec +38 -0
  71. metadata +172 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+ #ifndef ZSTDv06_H
11
+ #define ZSTDv06_H
12
+
13
+ #if defined (__cplusplus)
14
+ extern "C" {
15
+ #endif
16
+
17
+ /*====== Dependency ======*/
18
+ #include <stddef.h> /* size_t */
19
+
20
+
21
+ /*====== Export for Windows ======*/
22
+ /*!
23
+ * ZSTDv06_DLL_EXPORT :
24
+ * Enable exporting of functions when building a Windows DLL
25
+ */
26
+ #if defined(_WIN32) && defined(ZSTDv06_DLL_EXPORT) && (ZSTDv06_DLL_EXPORT==1)
27
+ # define ZSTDLIBv06_API __declspec(dllexport)
28
+ #else
29
+ # define ZSTDLIBv06_API
30
+ #endif
31
+
32
+
33
+ /* *************************************
34
+ * Simple functions
35
+ ***************************************/
36
+ /*! ZSTDv06_decompress() :
37
+ `compressedSize` : is the _exact_ size of the compressed blob, otherwise decompression will fail.
38
+ `dstCapacity` must be large enough, equal or larger than originalSize.
39
+ @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
40
+ or an errorCode if it fails (which can be tested using ZSTDv06_isError()) */
41
+ ZSTDLIBv06_API size_t ZSTDv06_decompress( void* dst, size_t dstCapacity,
42
+ const void* src, size_t compressedSize);
43
+
44
+
45
+ /* *************************************
46
+ * Helper functions
47
+ ***************************************/
48
+ ZSTDLIBv06_API size_t ZSTDv06_compressBound(size_t srcSize); /*!< maximum compressed size (worst case scenario) */
49
+
50
+ /* Error Management */
51
+ ZSTDLIBv06_API unsigned ZSTDv06_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
52
+ ZSTDLIBv06_API const char* ZSTDv06_getErrorName(size_t code); /*!< provides readable string for an error code */
53
+
54
+
55
+ /* *************************************
56
+ * Explicit memory management
57
+ ***************************************/
58
+ /** Decompression context */
59
+ typedef struct ZSTDv06_DCtx_s ZSTDv06_DCtx;
60
+ ZSTDLIBv06_API ZSTDv06_DCtx* ZSTDv06_createDCtx(void);
61
+ ZSTDLIBv06_API size_t ZSTDv06_freeDCtx(ZSTDv06_DCtx* dctx); /*!< @return : errorCode */
62
+
63
+ /** ZSTDv06_decompressDCtx() :
64
+ * Same as ZSTDv06_decompress(), but requires an already allocated ZSTDv06_DCtx (see ZSTDv06_createDCtx()) */
65
+ ZSTDLIBv06_API size_t ZSTDv06_decompressDCtx(ZSTDv06_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
66
+
67
+
68
+ /*-***********************
69
+ * Dictionary API
70
+ *************************/
71
+ /*! ZSTDv06_decompress_usingDict() :
72
+ * Decompression using a pre-defined Dictionary content (see dictBuilder).
73
+ * Dictionary must be identical to the one used during compression, otherwise regenerated data will be corrupted.
74
+ * Note : dict can be NULL, in which case, it's equivalent to ZSTDv06_decompressDCtx() */
75
+ ZSTDLIBv06_API size_t ZSTDv06_decompress_usingDict(ZSTDv06_DCtx* dctx,
76
+ void* dst, size_t dstCapacity,
77
+ const void* src, size_t srcSize,
78
+ const void* dict,size_t dictSize);
79
+
80
+
81
+ /*-************************
82
+ * Advanced Streaming API
83
+ ***************************/
84
+ struct ZSTDv06_frameParams_s { unsigned long long frameContentSize; unsigned windowLog; };
85
+ typedef struct ZSTDv06_frameParams_s ZSTDv06_frameParams;
86
+
87
+ ZSTDLIBv06_API size_t ZSTDv06_getFrameParams(ZSTDv06_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
88
+ ZSTDLIBv06_API size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, size_t dictSize);
89
+ ZSTDLIBv06_API void ZSTDv06_copyDCtx(ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx);
90
+
91
+ ZSTDLIBv06_API size_t ZSTDv06_nextSrcSizeToDecompress(ZSTDv06_DCtx* dctx);
92
+ ZSTDLIBv06_API size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
93
+
94
+
95
+
96
+ /* *************************************
97
+ * ZBUFF API
98
+ ***************************************/
99
+
100
+ typedef struct ZBUFFv06_DCtx_s ZBUFFv06_DCtx;
101
+ ZSTDLIBv06_API ZBUFFv06_DCtx* ZBUFFv06_createDCtx(void);
102
+ ZSTDLIBv06_API size_t ZBUFFv06_freeDCtx(ZBUFFv06_DCtx* dctx);
103
+
104
+ ZSTDLIBv06_API size_t ZBUFFv06_decompressInit(ZBUFFv06_DCtx* dctx);
105
+ ZSTDLIBv06_API size_t ZBUFFv06_decompressInitDictionary(ZBUFFv06_DCtx* dctx, const void* dict, size_t dictSize);
106
+
107
+ ZSTDLIBv06_API size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* dctx,
108
+ void* dst, size_t* dstCapacityPtr,
109
+ const void* src, size_t* srcSizePtr);
110
+
111
+ /*-***************************************************************************
112
+ * Streaming decompression howto
113
+ *
114
+ * A ZBUFFv06_DCtx object is required to track streaming operations.
115
+ * Use ZBUFFv06_createDCtx() and ZBUFFv06_freeDCtx() to create/release resources.
116
+ * Use ZBUFFv06_decompressInit() to start a new decompression operation,
117
+ * or ZBUFFv06_decompressInitDictionary() if decompression requires a dictionary.
118
+ * Note that ZBUFFv06_DCtx objects can be re-init multiple times.
119
+ *
120
+ * Use ZBUFFv06_decompressContinue() repetitively to consume your input.
121
+ * *srcSizePtr and *dstCapacityPtr can be any size.
122
+ * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
123
+ * Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
124
+ * The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
125
+ * @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to help latency),
126
+ * or 0 when a frame is completely decoded,
127
+ * or an error code, which can be tested using ZBUFFv06_isError().
128
+ *
129
+ * Hint : recommended buffer sizes (not compulsory) : ZBUFFv06_recommendedDInSize() and ZBUFFv06_recommendedDOutSize()
130
+ * output : ZBUFFv06_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
131
+ * input : ZBUFFv06_recommendedDInSize == 128KB + 3;
132
+ * just follow indications from ZBUFFv06_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
133
+ * *******************************************************************************/
134
+
135
+
136
+ /* *************************************
137
+ * Tool functions
138
+ ***************************************/
139
+ ZSTDLIBv06_API unsigned ZBUFFv06_isError(size_t errorCode);
140
+ ZSTDLIBv06_API const char* ZBUFFv06_getErrorName(size_t errorCode);
141
+
142
+ /** Functions below provide recommended buffer sizes for Compression or Decompression operations.
143
+ * These sizes are just hints, they tend to offer better latency */
144
+ ZSTDLIBv06_API size_t ZBUFFv06_recommendedDInSize(void);
145
+ ZSTDLIBv06_API size_t ZBUFFv06_recommendedDOutSize(void);
146
+
147
+
148
+ /*-*************************************
149
+ * Constants
150
+ ***************************************/
151
+ #define ZSTDv06_MAGICNUMBER 0xFD2FB526 /* v0.6 */
152
+
153
+
154
+
155
+ #if defined (__cplusplus)
156
+ }
157
+ #endif
158
+
159
+ #endif /* ZSTDv06_BUFFERED_H */