extzstd 0.0.3.CONCEPT-x86-mingw32 → 0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.ja +5 -0
  3. data/LICENSE +6 -6
  4. data/README.md +35 -22
  5. data/contrib/zstd/LICENSE +13 -9
  6. data/contrib/zstd/README.md +37 -44
  7. data/contrib/zstd/common/entropy_common.c +33 -39
  8. data/contrib/zstd/common/error_private.c +43 -0
  9. data/contrib/zstd/common/error_private.h +11 -60
  10. data/contrib/zstd/common/fse.h +11 -5
  11. data/contrib/zstd/common/fse_decompress.c +14 -16
  12. data/contrib/zstd/common/huf.h +1 -1
  13. data/contrib/zstd/common/mem.h +36 -43
  14. data/contrib/zstd/common/xxhash.c +31 -18
  15. data/contrib/zstd/common/xxhash.h +71 -35
  16. data/contrib/zstd/common/zbuff.h +29 -35
  17. data/contrib/zstd/common/zstd_common.c +24 -32
  18. data/contrib/zstd/common/zstd_errors.h +60 -0
  19. data/contrib/zstd/common/zstd_internal.h +109 -80
  20. data/contrib/zstd/compress/fse_compress.c +9 -6
  21. data/contrib/zstd/compress/huf_compress.c +30 -74
  22. data/contrib/zstd/compress/zbuff_compress.c +43 -51
  23. data/contrib/zstd/compress/zstd_compress.c +953 -763
  24. data/contrib/zstd/compress/zstd_opt.h +115 -261
  25. data/contrib/zstd/decompress/huf_decompress.c +29 -40
  26. data/contrib/zstd/decompress/zbuff_decompress.c +36 -78
  27. data/contrib/zstd/decompress/zstd_decompress.c +976 -496
  28. data/contrib/zstd/dictBuilder/divsufsort.h +5 -5
  29. data/contrib/zstd/dictBuilder/zdict.c +194 -229
  30. data/contrib/zstd/dictBuilder/zdict.h +66 -68
  31. data/contrib/zstd/legacy/zstd_legacy.h +168 -49
  32. data/contrib/zstd/legacy/zstd_v01.c +95 -178
  33. data/contrib/zstd/legacy/zstd_v01.h +12 -32
  34. data/contrib/zstd/legacy/zstd_v02.c +48 -274
  35. data/contrib/zstd/legacy/zstd_v02.h +12 -32
  36. data/contrib/zstd/legacy/zstd_v03.c +48 -274
  37. data/contrib/zstd/legacy/zstd_v03.h +12 -32
  38. data/contrib/zstd/legacy/zstd_v04.c +63 -320
  39. data/contrib/zstd/legacy/zstd_v04.h +13 -33
  40. data/contrib/zstd/legacy/zstd_v05.c +80 -345
  41. data/contrib/zstd/legacy/zstd_v05.h +9 -31
  42. data/contrib/zstd/legacy/zstd_v06.c +48 -458
  43. data/contrib/zstd/legacy/zstd_v06.h +41 -67
  44. data/contrib/zstd/legacy/zstd_v07.c +4544 -0
  45. data/contrib/zstd/legacy/zstd_v07.h +173 -0
  46. data/contrib/zstd/zstd.h +640 -0
  47. data/ext/extconf.rb +7 -3
  48. data/ext/extzstd.c +263 -106
  49. data/ext/extzstd.h +8 -6
  50. data/ext/extzstd_nogvls.h +0 -117
  51. data/ext/extzstd_stream.c +347 -0
  52. data/ext/zstd_common.c +8 -0
  53. data/ext/zstd_compress.c +6 -0
  54. data/ext/zstd_decompress.c +5 -0
  55. data/ext/zstd_dictbuilder.c +5 -0
  56. data/ext/zstd_legacy_v07.c +1 -0
  57. data/gemstub.rb +18 -16
  58. data/lib/2.1/extzstd.so +0 -0
  59. data/lib/2.2/extzstd.so +0 -0
  60. data/lib/2.3/extzstd.so +0 -0
  61. data/lib/extzstd/version.rb +1 -1
  62. data/lib/extzstd.rb +77 -43
  63. data/test/test_basic.rb +11 -6
  64. metadata +23 -11
  65. data/contrib/zstd/common/error_public.h +0 -77
  66. data/contrib/zstd/common/zstd.h +0 -475
  67. data/ext/extzstd_buffered.c +0 -265
  68. data/ext/zstd_amalgam.c +0 -18
  69. data/lib/2.0/extzstd.so +0 -0
data/ext/extzstd_nogvls.h CHANGED
@@ -54,121 +54,4 @@ aux_ZSTD_decompress(char *dest, size_t destsize, const char *src, size_t srcsize
54
54
  dest, destsize, src, srcsize);
55
55
  }
56
56
 
57
- static void *
58
- aux_ZBUFF_compressInit_nogvl(va_list *vp)
59
- {
60
- ZBUFF_CCtx *p = va_arg(*vp, ZBUFF_CCtx *);
61
- const void *dict = va_arg(*vp, const void *);
62
- size_t dictsize = va_arg(*vp, size_t);
63
- int level = va_arg(*vp, int);
64
- return (void *)ZBUFF_compressInitDictionary(p, dict, dictsize, level);
65
- }
66
-
67
- static inline size_t
68
- aux_ZBUFF_compressInitDictionary(ZBUFF_CCtx *p, const void* dict, size_t dictsize, int level)
69
- {
70
- return (size_t)aux_thread_call_without_gvl(
71
- aux_ZBUFF_compressInit_nogvl, NULL, p, dict, dictsize, level);
72
- }
73
-
74
- static inline void *
75
- aux_ZBUFF_compressInit_advanced_nogvl(va_list *vp)
76
- {
77
- ZBUFF_CCtx *p = va_arg(*vp, ZBUFF_CCtx *);
78
- const void *dict = va_arg(*vp, const void *);
79
- size_t dictsize = va_arg(*vp, size_t);
80
- const ZSTD_parameters *q = va_arg(*vp, const ZSTD_parameters *);
81
- unsigned long long pledgedsrcsize = va_arg(*vp, unsigned long long);
82
- return (void *)ZBUFF_compressInit_advanced(p, dict, dictsize, *q, pledgedsrcsize);
83
- }
84
-
85
- static inline size_t
86
- aux_ZBUFF_compressInit_advanced(ZBUFF_CCtx *p, const void *dict, size_t dictsize, const ZSTD_parameters *q, unsigned long long pledgedsrcsize)
87
- {
88
- return (size_t)aux_thread_call_without_gvl(
89
- aux_ZBUFF_compressInit_advanced_nogvl, NULL, p, dict, dictsize, q, pledgedsrcsize);
90
- }
91
-
92
- static inline void *
93
- aux_ZBUFF_compressContinue_nogvl(va_list *vp)
94
- {
95
- ZBUFF_CCtx *p = va_arg(*vp, ZBUFF_CCtx *);
96
- char *destp = va_arg(*vp, char *);
97
- size_t *destsize = va_arg(*vp, size_t *);
98
- const char *srcp = va_arg(*vp, const char *);
99
- size_t *srcsize = va_arg(*vp, size_t *);
100
- return (void *)ZBUFF_compressContinue(p, destp, destsize, srcp, srcsize);
101
- }
102
-
103
- static inline size_t
104
- aux_ZBUFF_compressContinue(ZBUFF_CCtx *p, char *destp, size_t *destsize, const char *srcp, size_t *srcsize)
105
- {
106
- return (size_t)aux_thread_call_without_gvl(
107
- aux_ZBUFF_compressContinue_nogvl, NULL, p, destp, destsize, srcp, srcsize);
108
- }
109
-
110
- static inline void *
111
- aux_ZBUFF_compressFlush_nogvl(va_list *vp)
112
- {
113
- ZBUFF_CCtx *p = va_arg(*vp, ZBUFF_CCtx *);
114
- char *destp = va_arg(*vp, char *);
115
- size_t *destsize = va_arg(*vp, size_t *);
116
- return (void *)ZBUFF_compressFlush(p, destp, destsize);
117
- }
118
-
119
- static inline size_t
120
- aux_ZBUFF_compressFlush(ZBUFF_CCtx *p, char *destp, size_t *destsize)
121
- {
122
- return (size_t)aux_thread_call_without_gvl(
123
- aux_ZBUFF_compressFlush_nogvl, NULL, p, destp, destsize);
124
- }
125
-
126
- static inline void *
127
- aux_ZBUFF_compressEnd_nogvl(va_list *vp)
128
- {
129
- ZBUFF_CCtx *p = va_arg(*vp, ZBUFF_CCtx *);
130
- char *destp = va_arg(*vp, char *);
131
- size_t *destsize = va_arg(*vp, size_t *);
132
- return (void *)ZBUFF_compressEnd(p, destp, destsize);
133
- }
134
-
135
- static inline size_t
136
- aux_ZBUFF_compressEnd(ZBUFF_CCtx *p, char *destp, size_t *destsize)
137
- {
138
- return (size_t)aux_thread_call_without_gvl(
139
- aux_ZBUFF_compressEnd_nogvl, NULL, p, destp, destsize);
140
- }
141
-
142
- static inline void *
143
- aux_ZBUFF_decompressInit_nogvl(va_list *vp)
144
- {
145
- ZBUFF_DCtx *p = va_arg(*vp, ZBUFF_DCtx *);
146
- return (void *)ZBUFF_decompressInit(p);
147
- }
148
-
149
- static inline size_t
150
- aux_ZBUFF_decompressInit(ZBUFF_DCtx *p)
151
- {
152
- return (size_t)aux_thread_call_without_gvl(
153
- aux_ZBUFF_decompressInit_nogvl, NULL, p);
154
- }
155
-
156
- static inline void *
157
- aux_ZBUFF_decompressContinue_nogvl(va_list *vp)
158
- {
159
- ZBUFF_DCtx *p = va_arg(*vp, ZBUFF_DCtx *);
160
- char *destp = va_arg(*vp, char *);
161
- size_t *destsize = va_arg(*vp, size_t *);
162
- const char *srcp = va_arg(*vp, const char *);
163
- size_t *srcsize = va_arg(*vp, size_t *);
164
- return (void *)ZBUFF_decompressContinue(p, destp, destsize, srcp, srcsize);
165
- }
166
-
167
- static inline size_t
168
- aux_ZBUFF_decompressContinue(ZBUFF_DCtx *p, char *destp, size_t *destsize, const char *srcp, size_t *srcsize)
169
- {
170
- return (size_t)aux_thread_call_without_gvl(
171
- aux_ZBUFF_decompressContinue_nogvl, NULL, p, destp, destsize, srcp, srcsize);
172
- }
173
-
174
57
  #endif /* EXTZSTD_NOGVLS_H */
@@ -0,0 +1,347 @@
1
+ #include "extzstd.h"
2
+ #include "extzstd_nogvls.h"
3
+ #include <errno.h>
4
+
5
+ /*
6
+ * class Zstd::StreamEncoder
7
+ */
8
+
9
+ static VALUE cStreamEncoder;
10
+
11
+ static void
12
+ enc_free(void *p)
13
+ {
14
+ ZSTD_freeCStream(p);
15
+ }
16
+
17
+ AUX_IMPLEMENT_CONTEXT(
18
+ ZSTD_CStream, encoder_type, "extzstd.Zstd::StreamEncoder",
19
+ encoder_alloc_dummy, NULL, enc_free, NULL,
20
+ getencoderp, getencoder, encoder_p);
21
+
22
+ static VALUE
23
+ enc_alloc(VALUE mod)
24
+ {
25
+ VALUE obj = TypedData_Wrap_Struct(mod, &encoder_type, NULL);
26
+
27
+ ZSTD_CStream *p = ZSTD_createCStream();
28
+ if (!p) {
29
+ rb_gc();
30
+ p = ZSTD_createCStream();
31
+ if (!p) {
32
+ errno = ENOMEM;
33
+ rb_sys_fail("failed ZSTD_createCStream()");
34
+ }
35
+ }
36
+ DATA_PTR(obj) = p;
37
+
38
+ return obj;
39
+ }
40
+
41
+ /*
42
+ * call-seq:
43
+ * initialize(compression_parameters, predict)
44
+ */
45
+ static VALUE
46
+ enc_init(VALUE self, VALUE params, VALUE predict)
47
+ {
48
+ /*
49
+ * ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
50
+ * ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel);
51
+ * ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
52
+ * ZSTD_parameters params, unsigned long long pledgedSrcSize);
53
+ */
54
+
55
+ ZSTD_CStream *p = getencoder(self);
56
+ const void *predictp;
57
+ size_t predictsize;
58
+ if (NIL_P(predict)) {
59
+ predictp = NULL;
60
+ predictsize = 0;
61
+ } else {
62
+ rb_check_type(predict, RUBY_T_STRING);
63
+ RSTRING_GETMEM(predict, predictp, predictsize);
64
+ }
65
+
66
+ if (extzstd_params_p(params)) {
67
+ ZSTD_parameters *paramsp = extzstd_getparams(params);
68
+ size_t s = ZSTD_initCStream_advanced(p, predictp, predictsize, *paramsp, 0);
69
+ extzstd_check_error(s);
70
+ } else {
71
+ size_t s = ZSTD_initCStream_usingDict(p, predictp, predictsize, aux_num2int(params, 1));
72
+ extzstd_check_error(s);
73
+ }
74
+ return self;
75
+ }
76
+
77
+ static VALUE
78
+ enc_update(VALUE self, VALUE src, VALUE srcoff, VALUE dest, VALUE maxdest)
79
+ {
80
+ /*
81
+ * ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
82
+ */
83
+
84
+ ZSTD_CStream *p = getencoder(self);
85
+
86
+ rb_check_type(src, RUBY_T_STRING);
87
+ const char *q = RSTRING_PTR(src);
88
+ const char *qq = RSTRING_END(src);
89
+ const char *q1 = q + NUM2SIZET(srcoff);
90
+ if (q1 < q || q1 > qq) {
91
+ rb_raise(rb_eArgError,
92
+ "``srcoff'' is out of range (given %"PRIuSIZE", expect 0..%"PRIuSIZE")",
93
+ q1 - q, qq - q);
94
+ }
95
+
96
+ rb_check_type(dest, RUBY_T_STRING);
97
+ rb_str_modify(dest);
98
+ rb_str_set_len(dest, 0);
99
+ rb_str_modify_expand(dest, NUM2SIZET(maxdest));
100
+ rb_obj_infect(self, src);
101
+ rb_obj_infect(dest, self);
102
+ char *r = RSTRING_PTR(dest);
103
+ const char *rr = r + rb_str_capacity(dest);
104
+
105
+ ZSTD_inBuffer input = { q, qq - q, q1 - q };
106
+ ZSTD_outBuffer output = { r, rr - r, 0 };
107
+ size_t s = ZSTD_compressStream(p, &output, &input);
108
+ extzstd_check_error(s);
109
+ rb_str_set_len(dest, output.pos);
110
+ if (input.pos == input.size) {
111
+ return Qnil;
112
+ } else {
113
+ return SIZET2NUM(input.pos);
114
+ }
115
+ }
116
+
117
+ static VALUE
118
+ enc_flush(VALUE self, VALUE dest, VALUE maxdest)
119
+ {
120
+ /*
121
+ * ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
122
+ */
123
+
124
+ ZSTD_CStream *p = getencoder(self);
125
+
126
+ rb_check_type(dest, RUBY_T_STRING);
127
+ rb_str_modify(dest);
128
+ rb_str_set_len(dest, 0);
129
+ rb_str_modify_expand(dest, NUM2SIZET(maxdest));
130
+
131
+ ZSTD_outBuffer output = { RSTRING_PTR(dest), rb_str_capacity(dest), 0 };
132
+ size_t s = ZSTD_flushStream(p, &output);
133
+ extzstd_check_error(s);
134
+ if (output.size > 0) {
135
+ rb_str_set_len(dest, output.pos);
136
+ return dest;
137
+ } else {
138
+ return Qnil;
139
+ }
140
+ }
141
+
142
+ static VALUE
143
+ enc_end(VALUE self, VALUE dest, VALUE maxdest)
144
+ {
145
+ /*
146
+ * ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
147
+ */
148
+
149
+ ZSTD_CStream *p = getencoder(self);
150
+ rb_check_type(dest, RUBY_T_STRING);
151
+ rb_str_modify(dest);
152
+ rb_str_set_len(dest, 0);
153
+ rb_str_modify_expand(dest, NUM2SIZET(maxdest));
154
+
155
+ ZSTD_outBuffer output = { RSTRING_PTR(dest), rb_str_capacity(dest), 0 };
156
+ size_t s = ZSTD_endStream(p, &output);
157
+ extzstd_check_error(s);
158
+ if (output.size > 0) {
159
+ rb_str_set_len(dest, output.pos);
160
+ return dest;
161
+ } else {
162
+ return Qnil;
163
+ }
164
+ }
165
+
166
+ static VALUE
167
+ enc_reset(VALUE self, VALUE pledged_srcsize)
168
+ {
169
+ /*
170
+ * ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
171
+ */
172
+
173
+ size_t s = ZSTD_resetCStream(getencoder(self), NUM2ULL(pledged_srcsize));
174
+ extzstd_check_error(s);
175
+ return self;
176
+ }
177
+
178
+ static VALUE
179
+ enc_sizeof(VALUE self)
180
+ {
181
+ /*
182
+ * ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
183
+ */
184
+
185
+ size_t s = ZSTD_sizeof_CStream(getencoder(self));
186
+ extzstd_check_error(s);
187
+ return SIZET2NUM(s);
188
+ }
189
+
190
+ static void
191
+ init_encoder(void)
192
+ {
193
+ cStreamEncoder = rb_define_class_under(extzstd_mZstd, "StreamEncoder", rb_cObject);
194
+ rb_define_alloc_func(cStreamEncoder, enc_alloc);
195
+ rb_define_const(cStreamEncoder, "INSIZE", SIZET2NUM(ZSTD_CStreamInSize()));
196
+ rb_define_const(cStreamEncoder, "OUTSIZE", SIZET2NUM(ZSTD_CStreamOutSize()));
197
+ rb_define_method(cStreamEncoder, "initialize", enc_init, 2);
198
+ rb_define_method(cStreamEncoder, "update", enc_update, 4);
199
+ rb_define_method(cStreamEncoder, "flush", enc_flush, 2);
200
+ rb_define_method(cStreamEncoder, "end", enc_end, 2);
201
+ rb_define_method(cStreamEncoder, "reset", enc_reset, 1);
202
+ rb_define_method(cStreamEncoder, "sizeof", enc_sizeof, 0);
203
+ }
204
+
205
+ /*
206
+ * class Zstd::StreamDecoder
207
+ */
208
+
209
+ static VALUE cStreamDecoder;
210
+
211
+ static void
212
+ dec_free(void *p)
213
+ {
214
+ ZSTD_freeDStream(p);
215
+ }
216
+
217
+ AUX_IMPLEMENT_CONTEXT(
218
+ ZSTD_DStream, decoder_type, "extzstd.Zstd::StreamDecoder",
219
+ decoder_alloc_dummy, NULL, dec_free, NULL,
220
+ getdecoderp, getdecoder, decoder_p);
221
+
222
+ static VALUE
223
+ dec_alloc(VALUE mod)
224
+ {
225
+ VALUE obj = TypedData_Wrap_Struct(mod, &decoder_type, NULL);
226
+
227
+ ZSTD_DStream *p = ZSTD_createDStream();
228
+ if (!p) {
229
+ rb_gc();
230
+ p = ZSTD_createDStream();
231
+ if (!p) {
232
+ errno = ENOMEM;
233
+ rb_sys_fail("failed ZSTD_createDStream()");
234
+ }
235
+ }
236
+ DATA_PTR(obj) = p;
237
+
238
+ return obj;
239
+ }
240
+
241
+ /*
242
+ * call-seq:
243
+ * initialize(predict)
244
+ */
245
+ static VALUE
246
+ dec_init(VALUE self, VALUE predict)
247
+ {
248
+ /*
249
+ * ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
250
+ * ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
251
+ */
252
+
253
+ ZSTD_DStream *p = getdecoder(self);
254
+
255
+ if (NIL_P(predict)) {
256
+ size_t s = ZSTD_initDStream(p);
257
+ extzstd_check_error(s);
258
+ } else {
259
+ rb_check_type(predict, RUBY_T_STRING);
260
+ size_t s = ZSTD_initDStream_usingDict(p, RSTRING_PTR(predict), RSTRING_LEN(predict));
261
+ extzstd_check_error(s);
262
+ }
263
+ return self;
264
+ }
265
+
266
+ static VALUE
267
+ dec_update(VALUE self, VALUE src, VALUE srcoff, VALUE dest, VALUE maxdest)
268
+ {
269
+ /*
270
+ * ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
271
+ */
272
+
273
+ ZSTD_DStream *p = getdecoder(self);
274
+
275
+ rb_check_type(src, RUBY_T_STRING);
276
+ const char *q = RSTRING_PTR(src);
277
+ const char *qq = RSTRING_END(src);
278
+ const char *q1 = q + NUM2SIZET(srcoff);
279
+ if (q1 < q || q1 > qq) {
280
+ rb_raise(rb_eArgError,
281
+ "``srcoff'' is out of range (given %"PRIuSIZE", expect 0..%"PRIuSIZE")",
282
+ q1 - q, qq - q);
283
+ }
284
+
285
+ rb_check_type(dest, RUBY_T_STRING);
286
+ rb_str_modify(dest);
287
+ rb_str_set_len(dest, 0);
288
+ rb_str_modify_expand(dest, NUM2SIZET(maxdest));
289
+ rb_obj_infect(self, src);
290
+ rb_obj_infect(dest, self);
291
+ char *r = RSTRING_PTR(dest);
292
+ const char *rr = r + rb_str_capacity(dest);
293
+
294
+ ZSTD_inBuffer input = { q, qq - q, q1 - q };
295
+ ZSTD_outBuffer output = { r, rr - r, 0 };
296
+ size_t s = ZSTD_decompressStream(p, &output, &input);
297
+ extzstd_check_error(s);
298
+ rb_str_set_len(dest, output.pos);
299
+ return SIZET2NUM(input.pos);
300
+ }
301
+
302
+ static VALUE
303
+ dec_reset(VALUE self)
304
+ {
305
+ /*
306
+ * ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
307
+ */
308
+ size_t s = ZSTD_resetDStream(getdecoder(self));
309
+ extzstd_check_error(s);
310
+ return self;
311
+ }
312
+
313
+ static VALUE
314
+ dec_sizeof(VALUE self)
315
+ {
316
+ /*
317
+ * ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
318
+ */
319
+
320
+ size_t s = ZSTD_sizeof_DStream(getdecoder(self));
321
+ extzstd_check_error(s);
322
+ return SIZET2NUM(s);
323
+ }
324
+
325
+ static void
326
+ init_decoder(void)
327
+ {
328
+ cStreamDecoder = rb_define_class_under(extzstd_mZstd, "StreamDecoder", rb_cObject);
329
+ rb_define_alloc_func(cStreamDecoder, dec_alloc);
330
+ rb_define_const(cStreamDecoder, "INSIZE", SIZET2NUM(ZSTD_DStreamInSize()));
331
+ rb_define_const(cStreamDecoder, "OUTSIZE", SIZET2NUM(ZSTD_DStreamOutSize()));
332
+ rb_define_method(cStreamDecoder, "initialize", dec_init, 1);
333
+ rb_define_method(cStreamDecoder, "update", dec_update, 4);
334
+ rb_define_method(cStreamDecoder, "reset", dec_reset, 0);
335
+ rb_define_method(cStreamDecoder, "sizeof", dec_sizeof, 0);
336
+ }
337
+
338
+ /*
339
+ * initialize for extzstd_stream.c
340
+ */
341
+
342
+ void
343
+ extzstd_init_stream(void)
344
+ {
345
+ init_encoder();
346
+ init_decoder();
347
+ }
data/ext/zstd_common.c ADDED
@@ -0,0 +1,8 @@
1
+ #define ZSTD_LEGACY_SUPPORT 1
2
+ #define MEM_MODULE 1
3
+
4
+ #include "../contrib/zstd/common/entropy_common.c"
5
+ #include "../contrib/zstd/common/error_private.c"
6
+ #include "../contrib/zstd/common/fse_decompress.c"
7
+ #include "../contrib/zstd/common/xxhash.c"
8
+ #include "../contrib/zstd/common/zstd_common.c"
@@ -0,0 +1,6 @@
1
+ #define ZSTD_LEGACY_SUPPORT 1
2
+ #define MEM_MODULE 1
3
+
4
+ #include "../contrib/zstd/compress/fse_compress.c"
5
+ #include "../contrib/zstd/compress/huf_compress.c"
6
+ #include "../contrib/zstd/compress/zstd_compress.c"
@@ -0,0 +1,5 @@
1
+ #define ZSTD_LEGACY_SUPPORT 1
2
+ #define MEM_MODULE 1
3
+
4
+ #include "../contrib/zstd/decompress/zstd_decompress.c"
5
+ #include "../contrib/zstd/decompress/huf_decompress.c"
@@ -0,0 +1,5 @@
1
+ #define ZSTD_LEGACY_SUPPORT 1
2
+ #define MEM_MODULE 1
3
+
4
+ #include "../contrib/zstd/dictBuilder/zdict.c"
5
+ #include "../contrib/zstd/dictBuilder/divsufsort.c"
@@ -0,0 +1 @@
1
+ #include "../contrib/zstd/legacy/zstd_v07.c"
data/gemstub.rb CHANGED
@@ -1,24 +1,13 @@
1
-
2
- file "lib/extzstd/version.rb" => %w(README.md) do
3
- reg = /^\s*\*\s+version:\s*(\d+(?:\.\w+)+)\s*$/i
4
- unless File.read("README.md", mode: "rt") =~ reg
5
- raise "``version'' is not defined or bad syntax in ``README.md''"
6
- end
7
-
8
- GEMSTUB.version = ver = String($1)
9
-
10
- File.write "lib/extzstd/version.rb", <<-"EOS", mode: "wb"
11
- module Zstd
12
- VERSION = #{ver.inspect}
13
- end
14
- EOS
1
+ verreg = /^\s*\*\s+version:\s*(\d+(?:\.\w+)+)\s*$/i
2
+ unless File.read("README.md", mode: "rt") =~ verreg
3
+ raise "``version'' is not defined or bad syntax in ``README.md''"
15
4
  end
16
5
 
17
- require_relative "lib/extzstd/version"
6
+ version = String($1)
18
7
 
19
8
  GEMSTUB = Gem::Specification.new do |s|
20
9
  s.name = "extzstd"
21
- s.version = Zstd::VERSION
10
+ s.version = version
22
11
  s.summary = "ruby bindings for Zstandard (zstd)"
23
12
  s.description = <<EOS
24
13
  unoficial ruby bindings for Zstandard (zstd) <https://github.com/Cyan4973/zstd>.
@@ -32,4 +21,17 @@ EOS
32
21
  s.add_development_dependency "rake"
33
22
  end
34
23
 
24
+ LIB << "lib/extzstd/version.rb"
25
+
26
+ file "lib/extzstd/version.rb" => %w(README.md) do
27
+ GEMSTUB.version = version
28
+
29
+ mkpath "lib/extzstd"
30
+ File.write "lib/extzstd/version.rb", <<-"EOS", mode: "wb"
31
+ module Zstd
32
+ VERSION = #{version.inspect}
33
+ end
34
+ EOS
35
+ end
36
+
35
37
  EXTRA.concat(FileList["contrib/**/*"])
data/lib/2.1/extzstd.so CHANGED
Binary file
data/lib/2.2/extzstd.so CHANGED
Binary file
data/lib/2.3/extzstd.so CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "0.0.3.CONCEPT"
2
+ VERSION = "0.1"
3
3
  end