extzstd 0.1.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/HISTORY.ja.md +18 -0
- data/README.md +15 -50
- data/contrib/zstd/CONTRIBUTING.md +1 -1
- data/contrib/zstd/COPYING +339 -0
- data/contrib/zstd/Makefile +82 -51
- data/contrib/zstd/NEWS +92 -5
- data/contrib/zstd/README.md +50 -41
- data/contrib/zstd/appveyor.yml +164 -102
- data/contrib/zstd/circle.yml +10 -22
- data/contrib/zstd/lib/BUCK +31 -10
- data/contrib/zstd/lib/Makefile +57 -31
- data/contrib/zstd/lib/README.md +68 -37
- data/contrib/zstd/lib/common/bitstream.h +130 -76
- data/contrib/zstd/lib/common/compiler.h +86 -0
- data/contrib/zstd/lib/common/error_private.c +15 -11
- data/contrib/zstd/lib/common/error_private.h +8 -8
- data/contrib/zstd/lib/common/fse.h +19 -9
- data/contrib/zstd/lib/common/fse_decompress.c +3 -22
- data/contrib/zstd/lib/common/huf.h +68 -26
- data/contrib/zstd/lib/common/mem.h +23 -35
- data/contrib/zstd/lib/common/pool.c +123 -63
- data/contrib/zstd/lib/common/pool.h +19 -10
- data/contrib/zstd/lib/common/threading.c +11 -16
- data/contrib/zstd/lib/common/threading.h +52 -33
- data/contrib/zstd/lib/common/xxhash.c +28 -22
- data/contrib/zstd/lib/common/zstd_common.c +40 -27
- data/contrib/zstd/lib/common/zstd_errors.h +43 -34
- data/contrib/zstd/lib/common/zstd_internal.h +131 -123
- data/contrib/zstd/lib/compress/fse_compress.c +17 -33
- data/contrib/zstd/lib/compress/huf_compress.c +15 -9
- data/contrib/zstd/lib/compress/zstd_compress.c +2096 -2363
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +462 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.c +309 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.h +29 -0
- data/contrib/zstd/lib/compress/zstd_fast.c +243 -0
- data/contrib/zstd/lib/compress/zstd_fast.h +31 -0
- data/contrib/zstd/lib/compress/zstd_lazy.c +765 -0
- data/contrib/zstd/lib/compress/zstd_lazy.h +39 -0
- data/contrib/zstd/lib/compress/zstd_ldm.c +707 -0
- data/contrib/zstd/lib/compress/zstd_ldm.h +68 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +785 -0
- data/contrib/zstd/lib/compress/zstd_opt.h +19 -908
- data/contrib/zstd/lib/compress/zstdmt_compress.c +737 -327
- data/contrib/zstd/lib/compress/zstdmt_compress.h +88 -26
- data/contrib/zstd/lib/decompress/huf_decompress.c +158 -50
- data/contrib/zstd/lib/decompress/zstd_decompress.c +884 -699
- data/contrib/zstd/lib/deprecated/zbuff.h +5 -4
- data/contrib/zstd/lib/deprecated/zbuff_common.c +5 -5
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +6 -4
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +5 -4
- data/contrib/zstd/lib/dictBuilder/cover.c +93 -77
- data/contrib/zstd/lib/dictBuilder/zdict.c +107 -92
- data/contrib/zstd/lib/dictBuilder/zdict.h +112 -102
- data/contrib/zstd/lib/legacy/zstd_legacy.h +9 -4
- data/contrib/zstd/lib/legacy/zstd_v01.c +7 -6
- data/contrib/zstd/lib/legacy/zstd_v01.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v02.c +27 -99
- data/contrib/zstd/lib/legacy/zstd_v02.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v03.c +26 -98
- data/contrib/zstd/lib/legacy/zstd_v03.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v04.c +22 -91
- data/contrib/zstd/lib/legacy/zstd_v04.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v05.c +23 -99
- data/contrib/zstd/lib/legacy/zstd_v05.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v06.c +22 -96
- data/contrib/zstd/lib/legacy/zstd_v06.h +5 -4
- data/contrib/zstd/lib/legacy/zstd_v07.c +19 -95
- data/contrib/zstd/lib/legacy/zstd_v07.h +5 -4
- data/contrib/zstd/lib/zstd.h +895 -271
- data/ext/extconf.rb +11 -2
- data/ext/extzstd.c +45 -128
- data/ext/extzstd.h +74 -31
- data/ext/extzstd_stream.c +401 -142
- data/ext/zstd_common.c +5 -0
- data/ext/zstd_compress.c +8 -0
- data/ext/zstd_decompress.c +1 -0
- data/ext/zstd_dictbuilder.c +2 -0
- data/lib/extzstd/version.rb +1 -1
- data/lib/extzstd.rb +48 -1
- data/test/test_basic.rb +9 -1
- metadata +17 -7
- data/HISTORY.ja +0 -10
- data/contrib/zstd/LICENSE-examples +0 -11
- data/contrib/zstd/PATENTS +0 -33
data/ext/extconf.rb
CHANGED
|
@@ -17,8 +17,17 @@ $INCFLAGS = %w(
|
|
|
17
17
|
#$srcs = files
|
|
18
18
|
#$VPATH.push "$(srcdir)/../contrib/zstd", "$(srcdir)/../contrib/zstd/legacy"
|
|
19
19
|
|
|
20
|
-
if RbConfig::CONFIG["arch"] =~ /mingw/
|
|
21
|
-
$LDFLAGS << " -static-libgcc"
|
|
20
|
+
if RbConfig::CONFIG["arch"] =~ /mingw/i
|
|
21
|
+
$LDFLAGS << " -static-libgcc" if try_ldflags("-static-libgcc")
|
|
22
|
+
else
|
|
23
|
+
if try_compile(<<-"VISIBILITY")
|
|
24
|
+
__attribute__ ((visibility("hidden"))) int conftest(void) { return 0; }
|
|
25
|
+
VISIBILITY
|
|
26
|
+
if try_cflags("-fvisibility=hidden")
|
|
27
|
+
$CFLAGS << " -fvisibility=hidden"
|
|
28
|
+
$defs << %('-DRBEXT_API=__attribute__ ((visibility("default")))')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
22
31
|
end
|
|
23
32
|
|
|
24
33
|
create_makefile File.join(RUBY_VERSION.slice(/\d+\.\d+/), "extzstd")
|
data/ext/extzstd.c
CHANGED
|
@@ -3,36 +3,11 @@
|
|
|
3
3
|
#include <zstd_errors.h>
|
|
4
4
|
#include <zdict.h>
|
|
5
5
|
|
|
6
|
-
static void
|
|
7
|
-
aux_string_pointer(VALUE str, const char **ptr, size_t *size)
|
|
8
|
-
{
|
|
9
|
-
rb_check_type(str, RUBY_T_STRING);
|
|
10
|
-
RSTRING_GETMEM(str, *ptr, *size);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static void
|
|
14
|
-
aux_string_pointer_with_nil(VALUE str, const char **ptr, size_t *size)
|
|
15
|
-
{
|
|
16
|
-
if (NIL_P(str)) {
|
|
17
|
-
*ptr = NULL;
|
|
18
|
-
*size = 0;
|
|
19
|
-
} else {
|
|
20
|
-
aux_string_pointer(str, ptr, size);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static void
|
|
25
|
-
aux_string_expand_pointer(VALUE str, char **ptr, size_t size)
|
|
26
|
-
{
|
|
27
|
-
rb_check_type(str, RUBY_T_STRING);
|
|
28
|
-
rb_str_modify(str);
|
|
29
|
-
rb_str_set_len(str, 0);
|
|
30
|
-
rb_str_modify_expand(str, size);
|
|
31
|
-
*ptr = RSTRING_PTR(str);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
6
|
VALUE extzstd_mZstd;
|
|
35
7
|
|
|
8
|
+
static ID id_initialize;
|
|
9
|
+
static ID id_error_code;
|
|
10
|
+
|
|
36
11
|
/*
|
|
37
12
|
* constant Zstd::LIBRARY_VERSION
|
|
38
13
|
*/
|
|
@@ -83,25 +58,6 @@ init_libver(void)
|
|
|
83
58
|
VALUE extzstd_mExceptions;
|
|
84
59
|
|
|
85
60
|
VALUE extzstd_eError;
|
|
86
|
-
VALUE extzstd_eError;
|
|
87
|
-
VALUE extzstd_eGenericError;
|
|
88
|
-
VALUE extzstd_ePrefixUnknownError;
|
|
89
|
-
VALUE extzstd_eFrameParameterUnsupportedError;
|
|
90
|
-
VALUE extzstd_eFrameParameterUnsupportedBy32bitsError;
|
|
91
|
-
VALUE extzstd_eCompressionParameterUnsupportedError;
|
|
92
|
-
VALUE extzstd_eInitMissingError;
|
|
93
|
-
VALUE extzstd_eMemoryAllocationError;
|
|
94
|
-
VALUE extzstd_eStageWrongError;
|
|
95
|
-
VALUE extzstd_eDstSizeTooSmallError;
|
|
96
|
-
VALUE extzstd_eSrcSizeWrongError;
|
|
97
|
-
VALUE extzstd_eCorruptionDetectedError;
|
|
98
|
-
VALUE extzstd_eChecksumWrongError;
|
|
99
|
-
VALUE extzstd_eTableLogTooLargeError;
|
|
100
|
-
VALUE extzstd_eMaxSymbolValueTooLargeError;
|
|
101
|
-
VALUE extzstd_eMaxSymbolValueTooSmallError;
|
|
102
|
-
VALUE extzstd_eDictionaryCorruptedError;
|
|
103
|
-
VALUE extzstd_eDictionaryWrongError;
|
|
104
|
-
|
|
105
61
|
|
|
106
62
|
void
|
|
107
63
|
extzstd_check_error(ssize_t errcode)
|
|
@@ -118,16 +74,18 @@ extzstd_error(ssize_t errcode)
|
|
|
118
74
|
}
|
|
119
75
|
|
|
120
76
|
VALUE
|
|
121
|
-
extzstd_make_errorf(
|
|
77
|
+
extzstd_make_errorf(ssize_t errcode, const char *fmt, ...)
|
|
122
78
|
{
|
|
79
|
+
VALUE e;
|
|
80
|
+
|
|
123
81
|
if (fmt && strlen(fmt) > 0) {
|
|
124
82
|
va_list va;
|
|
125
83
|
va_start(va, fmt);
|
|
126
84
|
VALUE mesg = rb_vsprintf(fmt, va);
|
|
127
85
|
va_end(va);
|
|
128
|
-
return
|
|
86
|
+
return AUX_FUNCALL(extzstd_eError, id_initialize, SSIZET2NUM(errcode), mesg);
|
|
129
87
|
} else {
|
|
130
|
-
return
|
|
88
|
+
return AUX_FUNCALL(extzstd_eError, id_initialize, SSIZET2NUM(errcode));
|
|
131
89
|
}
|
|
132
90
|
}
|
|
133
91
|
|
|
@@ -136,33 +94,34 @@ extzstd_make_error(ssize_t errcode)
|
|
|
136
94
|
{
|
|
137
95
|
if (!ZSTD_isError(errcode)) { return Qnil; }
|
|
138
96
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
CASE_ERROR(ZSTD_error_corruption_detected, extzstd_eCorruptionDetectedError, NULL);
|
|
154
|
-
CASE_ERROR(ZSTD_error_checksum_wrong, extzstd_eChecksumWrongError, NULL);
|
|
155
|
-
CASE_ERROR(ZSTD_error_tableLog_tooLarge, extzstd_eTableLogTooLargeError, NULL);
|
|
156
|
-
CASE_ERROR(ZSTD_error_maxSymbolValue_tooLarge, extzstd_eMaxSymbolValueTooLargeError, NULL);
|
|
157
|
-
CASE_ERROR(ZSTD_error_maxSymbolValue_tooSmall, extzstd_eMaxSymbolValueTooSmallError, NULL);
|
|
158
|
-
CASE_ERROR(ZSTD_error_dictionary_corrupted, extzstd_eDictionaryCorruptedError, NULL);
|
|
159
|
-
CASE_ERROR(ZSTD_error_dictionary_wrong, extzstd_eDictionaryWrongError, NULL);
|
|
160
|
-
default:
|
|
161
|
-
return extzstd_make_errorf(extzstd_eError,
|
|
162
|
-
"unknown zstd error code (%d)", errcode);
|
|
163
|
-
}
|
|
97
|
+
return extzstd_make_errorf(ZSTD_getErrorCode(errcode), NULL);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static VALUE
|
|
101
|
+
err_initialize(int argc, VALUE argv[], VALUE err)
|
|
102
|
+
{
|
|
103
|
+
VALUE errcode;
|
|
104
|
+
|
|
105
|
+
rb_scan_args(argc, argv, "1*", &errcode, NULL);
|
|
106
|
+
rb_call_super(argc - 1, argv + 1);
|
|
107
|
+
rb_ivar_set(err, id_error_code, errcode);
|
|
108
|
+
|
|
109
|
+
return err;
|
|
110
|
+
}
|
|
164
111
|
|
|
165
|
-
|
|
112
|
+
static VALUE
|
|
113
|
+
err_errcode(VALUE err)
|
|
114
|
+
{
|
|
115
|
+
return rb_ivar_get(err, id_error_code);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static VALUE
|
|
119
|
+
err_to_s(VALUE err)
|
|
120
|
+
{
|
|
121
|
+
ZSTD_ErrorCode code = (ZSTD_ErrorCode)NUM2SSIZET(rb_ivar_get(err, id_error_code));
|
|
122
|
+
VALUE mesg = rb_call_super(0, NULL);
|
|
123
|
+
VALUE mesg2 = rb_sprintf(" - %s (errcode: %d)", ZSTD_getErrorString(code), (int)code);
|
|
124
|
+
return rb_str_plus(mesg, mesg2);
|
|
166
125
|
}
|
|
167
126
|
|
|
168
127
|
static void
|
|
@@ -172,57 +131,10 @@ init_error(void)
|
|
|
172
131
|
|
|
173
132
|
extzstd_eError = rb_define_class_under(extzstd_mZstd, "Error", rb_eRuntimeError);
|
|
174
133
|
rb_include_module(extzstd_eError, extzstd_mExceptions);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
extzstd_ePrefixUnknownError = rb_define_class_under(extzstd_mZstd, "PrefixUnknownError", rb_eArgError);
|
|
180
|
-
rb_include_module(extzstd_ePrefixUnknownError, extzstd_mExceptions);
|
|
181
|
-
|
|
182
|
-
extzstd_eFrameParameterUnsupportedError = rb_define_class_under(extzstd_mZstd, "FrameParameterUnsupportedError", rb_eRuntimeError);
|
|
183
|
-
rb_include_module(extzstd_eFrameParameterUnsupportedError, extzstd_mExceptions);
|
|
184
|
-
|
|
185
|
-
extzstd_eFrameParameterUnsupportedBy32bitsError = rb_define_class_under(extzstd_mZstd, "FrameParameterUnsupportedBy32bitsImplementationError", rb_eRuntimeError);
|
|
186
|
-
rb_include_module(extzstd_eFrameParameterUnsupportedBy32bitsError, extzstd_mExceptions);
|
|
187
|
-
|
|
188
|
-
extzstd_eCompressionParameterUnsupportedError = rb_define_class_under(extzstd_mZstd, "CompressionParameterUnsupportedError", rb_eRuntimeError);
|
|
189
|
-
rb_include_module(extzstd_eCompressionParameterUnsupportedError, extzstd_mExceptions);
|
|
190
|
-
|
|
191
|
-
extzstd_eInitMissingError = rb_define_class_under(extzstd_mZstd, "InitMissingError", rb_eRuntimeError);
|
|
192
|
-
rb_include_module(extzstd_eInitMissingError, extzstd_mExceptions);
|
|
193
|
-
|
|
194
|
-
extzstd_eMemoryAllocationError = rb_define_class_under(extzstd_mZstd, "MemoryAllocationError", aux_const_dig_str(rb_cObject, "Errno", "ENOMEM"));
|
|
195
|
-
rb_include_module(extzstd_eMemoryAllocationError, extzstd_mExceptions);
|
|
196
|
-
|
|
197
|
-
extzstd_eStageWrongError = rb_define_class_under(extzstd_mZstd, "StageWrongError", rb_eRuntimeError);
|
|
198
|
-
rb_include_module(extzstd_eStageWrongError, extzstd_mExceptions);
|
|
199
|
-
|
|
200
|
-
extzstd_eDstSizeTooSmallError = rb_define_class_under(extzstd_mZstd, "DstSizeTooSmallError", rb_eArgError);
|
|
201
|
-
rb_include_module(extzstd_eDstSizeTooSmallError, extzstd_mExceptions);
|
|
202
|
-
|
|
203
|
-
extzstd_eSrcSizeWrongError = rb_define_class_under(extzstd_mZstd, "SrcSizeWrongError", rb_eArgError);
|
|
204
|
-
rb_include_module(extzstd_eSrcSizeWrongError, extzstd_mExceptions);
|
|
205
|
-
|
|
206
|
-
extzstd_eCorruptionDetectedError = rb_define_class_under(extzstd_mZstd, "CorruptionDetectedError", rb_eRuntimeError);
|
|
207
|
-
rb_include_module(extzstd_eCorruptionDetectedError, extzstd_mExceptions);
|
|
208
|
-
|
|
209
|
-
extzstd_eChecksumWrongError = rb_define_class_under(extzstd_mZstd, "ChecksumWrongError", rb_eRuntimeError);
|
|
210
|
-
rb_include_module(extzstd_eChecksumWrongError, extzstd_mExceptions);
|
|
211
|
-
|
|
212
|
-
extzstd_eTableLogTooLargeError = rb_define_class_under(extzstd_mZstd, "TableLogTooLargeError", rb_eArgError);
|
|
213
|
-
rb_include_module(extzstd_eTableLogTooLargeError, extzstd_mExceptions);
|
|
214
|
-
|
|
215
|
-
extzstd_eMaxSymbolValueTooLargeError = rb_define_class_under(extzstd_mZstd, "MaxSymbolValueTooLargeError", rb_eArgError);
|
|
216
|
-
rb_include_module(extzstd_eMaxSymbolValueTooLargeError, extzstd_mExceptions);
|
|
217
|
-
|
|
218
|
-
extzstd_eMaxSymbolValueTooSmallError = rb_define_class_under(extzstd_mZstd, "MaxSymbolValueTooSmallError", rb_eArgError);
|
|
219
|
-
rb_include_module(extzstd_eMaxSymbolValueTooSmallError, extzstd_mExceptions);
|
|
220
|
-
|
|
221
|
-
extzstd_eDictionaryCorruptedError = rb_define_class_under(extzstd_mZstd, "DictionaryCorruptedError", rb_eRuntimeError);
|
|
222
|
-
rb_include_module(extzstd_eDictionaryCorruptedError, extzstd_mExceptions);
|
|
223
|
-
|
|
224
|
-
extzstd_eDictionaryWrongError = rb_define_class_under(extzstd_mZstd, "DictionaryWrongError", rb_eRuntimeError);
|
|
225
|
-
rb_include_module(extzstd_eDictionaryWrongError, extzstd_mExceptions);
|
|
134
|
+
rb_define_method(extzstd_eError, "initialize", err_initialize, -1);
|
|
135
|
+
rb_define_method(extzstd_eError, "error_code", err_errcode, 0);
|
|
136
|
+
rb_define_method(extzstd_eError, "to_s", err_to_s, 0);
|
|
137
|
+
rb_define_alias(extzstd_eError, "errcode", "error_code");
|
|
226
138
|
}
|
|
227
139
|
|
|
228
140
|
/*
|
|
@@ -245,6 +157,7 @@ init_constants(void)
|
|
|
245
157
|
rb_define_const(mConstants, "ZSTD_LAZY2", INT2NUM(ZSTD_lazy2));
|
|
246
158
|
rb_define_const(mConstants, "ZSTD_BTLAZY2", INT2NUM(ZSTD_btlazy2));
|
|
247
159
|
rb_define_const(mConstants, "ZSTD_BTOPT", INT2NUM(ZSTD_btopt));
|
|
160
|
+
rb_define_const(mConstants, "ZSTD_BTULTRA", INT2NUM(ZSTD_btultra));
|
|
248
161
|
rb_define_const(mConstants, "ZSTD_WINDOWLOG_MAX", INT2NUM(ZSTD_WINDOWLOG_MAX));
|
|
249
162
|
rb_define_const(mConstants, "ZSTD_WINDOWLOG_MIN", INT2NUM(ZSTD_WINDOWLOG_MIN));
|
|
250
163
|
rb_define_const(mConstants, "ZSTD_HASHLOG_MAX", INT2NUM(ZSTD_HASHLOG_MAX));
|
|
@@ -266,6 +179,7 @@ init_constants(void)
|
|
|
266
179
|
rb_define_const(mConstants, "LAZY2", INT2NUM(ZSTD_lazy2));
|
|
267
180
|
rb_define_const(mConstants, "BTLAZY2", INT2NUM(ZSTD_btlazy2));
|
|
268
181
|
rb_define_const(mConstants, "BTOPT", INT2NUM(ZSTD_btopt));
|
|
182
|
+
rb_define_const(mConstants, "BTULTRA", INT2NUM(ZSTD_btultra));
|
|
269
183
|
rb_define_const(mConstants, "WINDOWLOG_MAX", INT2NUM(ZSTD_WINDOWLOG_MAX));
|
|
270
184
|
rb_define_const(mConstants, "WINDOWLOG_MIN", INT2NUM(ZSTD_WINDOWLOG_MIN));
|
|
271
185
|
rb_define_const(mConstants, "HASHLOG_MAX", INT2NUM(ZSTD_HASHLOG_MAX));
|
|
@@ -688,9 +602,12 @@ init_contextless(void)
|
|
|
688
602
|
* library initializer
|
|
689
603
|
*/
|
|
690
604
|
|
|
691
|
-
void
|
|
605
|
+
RBEXT_API void
|
|
692
606
|
Init_extzstd(void)
|
|
693
607
|
{
|
|
608
|
+
id_initialize = rb_intern("initialize");
|
|
609
|
+
id_error_code = rb_intern("error_code");
|
|
610
|
+
|
|
694
611
|
extzstd_mZstd = rb_define_module("Zstd");
|
|
695
612
|
|
|
696
613
|
init_libver();
|
data/ext/extzstd.h
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
#define ZSTD_LEGACY_SUPPORT 1
|
|
5
5
|
#define ZDICT_STATIC_LINKING_ONLY 1
|
|
6
|
-
|
|
6
|
+
//#define ZSTD_STATIC_LINKING_ONLY 1
|
|
7
|
+
#include <common/zstd_internal.h> /* for MIN() */
|
|
7
8
|
#include <zstd.h>
|
|
8
9
|
#include <stdarg.h>
|
|
9
10
|
#include <ruby.h>
|
|
@@ -28,24 +29,6 @@ RDOCFAKE(extzstd_cParams = rb_define_class_under(extzstd_mZstd, "Parameters", rb
|
|
|
28
29
|
|
|
29
30
|
extern VALUE extzstd_mExceptions;
|
|
30
31
|
extern VALUE extzstd_eError;
|
|
31
|
-
extern VALUE extzstd_eGenericError;
|
|
32
|
-
extern VALUE extzstd_ePrefixUnknownError;
|
|
33
|
-
extern VALUE extzstd_eFrameParameterUnsupportedError;
|
|
34
|
-
extern VALUE extzstd_eFrameParameterUnsupportedBy32bitsError;
|
|
35
|
-
extern VALUE extzstd_eCompressionParameterUnsupportedError;
|
|
36
|
-
extern VALUE extzstd_eInitMissingError;
|
|
37
|
-
extern VALUE extzstd_eMemoryAllocationError;
|
|
38
|
-
extern VALUE extzstd_eStageWrongError;
|
|
39
|
-
extern VALUE extzstd_eDstSizeTooSmallError;
|
|
40
|
-
extern VALUE extzstd_eSrcSizeWrongError;
|
|
41
|
-
extern VALUE extzstd_eCorruptionDetectedError;
|
|
42
|
-
extern VALUE extzstd_eChecksumWrongError;
|
|
43
|
-
extern VALUE extzstd_eTableLogTooLargeError;
|
|
44
|
-
extern VALUE extzstd_eMaxSymbolValueTooLargeError;
|
|
45
|
-
extern VALUE extzstd_eMaxSymbolValueTooSmallError;
|
|
46
|
-
extern VALUE extzstd_eDictionaryCorruptedError;
|
|
47
|
-
extern VALUE extzstd_eDictionaryWrongError;
|
|
48
|
-
|
|
49
32
|
|
|
50
33
|
extern void init_extzstd_stream(void);
|
|
51
34
|
extern void extzstd_init_buffered(void);
|
|
@@ -53,7 +36,7 @@ extern void extzstd_init_stream(void);
|
|
|
53
36
|
extern void extzstd_error(ssize_t errcode);
|
|
54
37
|
extern void extzstd_check_error(ssize_t errcode);
|
|
55
38
|
extern VALUE extzstd_make_error(ssize_t errcode);
|
|
56
|
-
extern VALUE extzstd_make_errorf(
|
|
39
|
+
extern VALUE extzstd_make_errorf(ssize_t errcode, const char *fmt, ...);
|
|
57
40
|
|
|
58
41
|
extern ZSTD_parameters *extzstd_getparams(VALUE v);
|
|
59
42
|
extern int extzstd_params_p(VALUE v);
|
|
@@ -171,16 +154,76 @@ aux_const_dig_str_0(VALUE obj, const char *p[], const char **pp)
|
|
|
171
154
|
return obj;
|
|
172
155
|
}
|
|
173
156
|
|
|
174
|
-
#define aux_const_dig_str(OBJ, ...)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
157
|
+
#define aux_const_dig_str(OBJ, ...) \
|
|
158
|
+
aux_const_dig_str_0((OBJ), \
|
|
159
|
+
((const char *[]){ __VA_ARGS__ }), \
|
|
160
|
+
ENDOF(((const char *[]){ __VA_ARGS__ }))) \
|
|
161
|
+
|
|
162
|
+
#define AUX_TUPLE(...) \
|
|
163
|
+
rb_ary_new4(ELEMENTOF(((VALUE[]) { __VA_ARGS__ })), \
|
|
164
|
+
((VALUE[]) { __VA_ARGS__ })) \
|
|
165
|
+
|
|
166
|
+
#define AUX_FUNCALL(RECV, MID, ...) \
|
|
167
|
+
rb_funcall2((RECV), (MID), \
|
|
168
|
+
ELEMENTOF(((const VALUE[]){ __VA_ARGS__ })), \
|
|
169
|
+
((const VALUE[]){ __VA_ARGS__ })) \
|
|
170
|
+
|
|
171
|
+
#define AUX_TRY_WITH_GC(cond, mesg) \
|
|
172
|
+
do { \
|
|
173
|
+
if (!(cond)) { \
|
|
174
|
+
rb_gc(); \
|
|
175
|
+
if (!(cond)) { \
|
|
176
|
+
errno = ENOMEM; \
|
|
177
|
+
rb_sys_fail(mesg); \
|
|
178
|
+
} \
|
|
179
|
+
} \
|
|
180
|
+
} while (0) \
|
|
181
|
+
|
|
182
|
+
#if defined _WIN32 || defined __CYGWIN__
|
|
183
|
+
# define RBEXT_IMPORT __declspec(dllimport)
|
|
184
|
+
# define RBEXT_EXPORT __declspec(dllexport)
|
|
185
|
+
# define RBEXT_LOCAL
|
|
186
|
+
#elif __GNUC__ >= 4 || __clang__
|
|
187
|
+
# define RBEXT_IMPORT __attribute__((visibility("default")))
|
|
188
|
+
# define RBEXT_EXPORT __attribute__((visibility("default")))
|
|
189
|
+
# define RBEXT_LOCAL __attribute__((visibility("hidden")))
|
|
190
|
+
#else
|
|
191
|
+
# define RBEXT_IMPORT
|
|
192
|
+
# define RBEXT_EXPORT
|
|
193
|
+
# define RBEXT_LOCAL
|
|
194
|
+
#endif
|
|
195
|
+
|
|
196
|
+
#ifndef RBEXT_API
|
|
197
|
+
# define RBEXT_API RBEXT_EXPORT
|
|
198
|
+
#endif
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
static void
|
|
202
|
+
aux_string_pointer(VALUE str, const char **ptr, size_t *size)
|
|
203
|
+
{
|
|
204
|
+
rb_check_type(str, RUBY_T_STRING);
|
|
205
|
+
RSTRING_GETMEM(str, *ptr, *size);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static void
|
|
209
|
+
aux_string_pointer_with_nil(VALUE str, const char **ptr, size_t *size)
|
|
210
|
+
{
|
|
211
|
+
if (NIL_P(str)) {
|
|
212
|
+
*ptr = NULL;
|
|
213
|
+
*size = 0;
|
|
214
|
+
} else {
|
|
215
|
+
aux_string_pointer(str, ptr, size);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static void
|
|
220
|
+
aux_string_expand_pointer(VALUE str, char **ptr, size_t size)
|
|
221
|
+
{
|
|
222
|
+
rb_check_type(str, RUBY_T_STRING);
|
|
223
|
+
rb_str_modify(str);
|
|
224
|
+
rb_str_set_len(str, 0);
|
|
225
|
+
rb_str_modify_expand(str, size);
|
|
226
|
+
*ptr = RSTRING_PTR(str);
|
|
227
|
+
}
|
|
185
228
|
|
|
186
229
|
#endif /* EXTZSTD_H */
|