zstd-ruby 1.5.2.3 → 1.5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/ext/zstdruby/extconf.rb +1 -1
- data/ext/zstdruby/libzstd/common/bits.h +175 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +18 -59
- data/ext/zstdruby/libzstd/common/compiler.h +22 -3
- data/ext/zstdruby/libzstd/common/cpu.h +1 -1
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +1 -1
- data/ext/zstdruby/libzstd/common/entropy_common.c +12 -40
- data/ext/zstdruby/libzstd/common/error_private.c +9 -2
- data/ext/zstdruby/libzstd/common/error_private.h +1 -1
- data/ext/zstdruby/libzstd/common/fse.h +5 -83
- data/ext/zstdruby/libzstd/common/fse_decompress.c +7 -99
- data/ext/zstdruby/libzstd/common/huf.h +65 -156
- data/ext/zstdruby/libzstd/common/mem.h +39 -46
- data/ext/zstdruby/libzstd/common/pool.c +26 -10
- data/ext/zstdruby/libzstd/common/pool.h +7 -1
- data/ext/zstdruby/libzstd/common/portability_macros.h +22 -3
- data/ext/zstdruby/libzstd/common/threading.c +68 -14
- data/ext/zstdruby/libzstd/common/threading.h +5 -10
- data/ext/zstdruby/libzstd/common/xxhash.c +2 -2
- data/ext/zstdruby/libzstd/common/xxhash.h +8 -8
- data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
- data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +17 -113
- data/ext/zstdruby/libzstd/common/zstd_trace.h +3 -3
- data/ext/zstdruby/libzstd/compress/clevels.h +1 -1
- data/ext/zstdruby/libzstd/compress/fse_compress.c +7 -124
- data/ext/zstdruby/libzstd/compress/hist.c +1 -1
- data/ext/zstdruby/libzstd/compress/hist.h +1 -1
- data/ext/zstdruby/libzstd/compress/huf_compress.c +234 -169
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1055 -455
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +165 -145
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +115 -39
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -8
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +3 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +5 -3
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +95 -33
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +433 -148
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +306 -283
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +4 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -5
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +104 -80
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +12 -5
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +1 -1
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +434 -441
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +30 -39
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +3 -4
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +164 -42
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +186 -65
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +4 -2
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +19 -15
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +2 -2
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +9 -87
- data/ext/zstdruby/libzstd/zdict.h +53 -31
- data/ext/zstdruby/libzstd/zstd.h +489 -90
- data/ext/zstdruby/libzstd/zstd_errors.h +27 -8
- data/ext/zstdruby/main.c +6 -0
- data/ext/zstdruby/skippable_frame.c +63 -0
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +8 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
@@ -20,19 +20,31 @@ extern "C" {
|
|
20
20
|
|
21
21
|
|
22
22
|
/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
|
23
|
-
#ifndef
|
24
|
-
|
25
|
-
#
|
23
|
+
#ifndef ZSTDERRORLIB_VISIBLE
|
24
|
+
/* Backwards compatibility with old macro name */
|
25
|
+
# ifdef ZSTDERRORLIB_VISIBILITY
|
26
|
+
# define ZSTDERRORLIB_VISIBLE ZSTDERRORLIB_VISIBILITY
|
27
|
+
# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
28
|
+
# define ZSTDERRORLIB_VISIBLE __attribute__ ((visibility ("default")))
|
26
29
|
# else
|
27
|
-
# define
|
30
|
+
# define ZSTDERRORLIB_VISIBLE
|
28
31
|
# endif
|
29
32
|
#endif
|
33
|
+
|
34
|
+
#ifndef ZSTDERRORLIB_HIDDEN
|
35
|
+
# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
36
|
+
# define ZSTDERRORLIB_HIDDEN __attribute__ ((visibility ("hidden")))
|
37
|
+
# else
|
38
|
+
# define ZSTDERRORLIB_HIDDEN
|
39
|
+
# endif
|
40
|
+
#endif
|
41
|
+
|
30
42
|
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
31
|
-
# define ZSTDERRORLIB_API __declspec(dllexport)
|
43
|
+
# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBLE
|
32
44
|
#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
33
|
-
# define ZSTDERRORLIB_API __declspec(dllimport)
|
45
|
+
# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
34
46
|
#else
|
35
|
-
# define ZSTDERRORLIB_API
|
47
|
+
# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBLE
|
36
48
|
#endif
|
37
49
|
|
38
50
|
/*-*********************************************
|
@@ -58,14 +70,17 @@ typedef enum {
|
|
58
70
|
ZSTD_error_frameParameter_windowTooLarge = 16,
|
59
71
|
ZSTD_error_corruption_detected = 20,
|
60
72
|
ZSTD_error_checksum_wrong = 22,
|
73
|
+
ZSTD_error_literals_headerWrong = 24,
|
61
74
|
ZSTD_error_dictionary_corrupted = 30,
|
62
75
|
ZSTD_error_dictionary_wrong = 32,
|
63
76
|
ZSTD_error_dictionaryCreation_failed = 34,
|
64
77
|
ZSTD_error_parameter_unsupported = 40,
|
78
|
+
ZSTD_error_parameter_combination_unsupported = 41,
|
65
79
|
ZSTD_error_parameter_outOfBound = 42,
|
66
80
|
ZSTD_error_tableLog_tooLarge = 44,
|
67
81
|
ZSTD_error_maxSymbolValue_tooLarge = 46,
|
68
82
|
ZSTD_error_maxSymbolValue_tooSmall = 48,
|
83
|
+
ZSTD_error_stabilityCondition_notRespected = 50,
|
69
84
|
ZSTD_error_stage_wrong = 60,
|
70
85
|
ZSTD_error_init_missing = 62,
|
71
86
|
ZSTD_error_memory_allocation = 64,
|
@@ -73,11 +88,15 @@ typedef enum {
|
|
73
88
|
ZSTD_error_dstSize_tooSmall = 70,
|
74
89
|
ZSTD_error_srcSize_wrong = 72,
|
75
90
|
ZSTD_error_dstBuffer_null = 74,
|
91
|
+
ZSTD_error_noForwardProgress_destFull = 80,
|
92
|
+
ZSTD_error_noForwardProgress_inputEmpty = 82,
|
76
93
|
/* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
|
77
94
|
ZSTD_error_frameIndex_tooLarge = 100,
|
78
95
|
ZSTD_error_seekableIO = 102,
|
79
96
|
ZSTD_error_dstBuffer_wrong = 104,
|
80
97
|
ZSTD_error_srcBuffer_wrong = 105,
|
98
|
+
ZSTD_error_sequenceProducer_failed = 106,
|
99
|
+
ZSTD_error_externalSequences_invalid = 107,
|
81
100
|
ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
|
82
101
|
} ZSTD_ErrorCode;
|
83
102
|
|
data/ext/zstdruby/main.c
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
#include <common.h>
|
2
2
|
VALUE rb_mZstd;
|
3
3
|
void zstd_ruby_init(void);
|
4
|
+
void zstd_ruby_skippable_frame_init(void);
|
4
5
|
void zstd_ruby_streaming_compress_init(void);
|
5
6
|
void zstd_ruby_streaming_decompress_init(void);
|
6
7
|
|
7
8
|
void
|
8
9
|
Init_zstdruby(void)
|
9
10
|
{
|
11
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
12
|
+
rb_ext_ractor_safe(true);
|
13
|
+
#endif
|
14
|
+
|
10
15
|
rb_mZstd = rb_define_module("Zstd");
|
11
16
|
zstd_ruby_init();
|
17
|
+
zstd_ruby_skippable_frame_init();
|
12
18
|
zstd_ruby_streaming_compress_init();
|
13
19
|
zstd_ruby_streaming_decompress_init();
|
14
20
|
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#include <common.h>
|
2
|
+
|
3
|
+
extern VALUE rb_mZstd;
|
4
|
+
|
5
|
+
static VALUE rb_write_skippable_frame(int argc, VALUE *argv, VALUE self)
|
6
|
+
{
|
7
|
+
VALUE input_value;
|
8
|
+
VALUE skip_value;
|
9
|
+
VALUE kwargs;
|
10
|
+
rb_scan_args(argc, argv, "2:", &input_value, &skip_value, &kwargs);
|
11
|
+
|
12
|
+
ID kwargs_keys[1];
|
13
|
+
kwargs_keys[0] = rb_intern("magic_variant");
|
14
|
+
VALUE kwargs_values[1];
|
15
|
+
rb_get_kwargs(kwargs, kwargs_keys, 0, 1, kwargs_values);
|
16
|
+
unsigned magic_variant = (kwargs_values[0] != Qundef) ? (NUM2INT(kwargs_values[0])) : 0;
|
17
|
+
|
18
|
+
StringValue(input_value);
|
19
|
+
StringValue(skip_value);
|
20
|
+
char* input_data = RSTRING_PTR(input_value);
|
21
|
+
size_t input_size = RSTRING_LEN(input_value);
|
22
|
+
char* skip_data = RSTRING_PTR(skip_value);
|
23
|
+
size_t skip_size = RSTRING_LEN(skip_value);
|
24
|
+
|
25
|
+
size_t dst_size = input_size + ZSTD_SKIPPABLEHEADERSIZE + skip_size;
|
26
|
+
VALUE output = rb_str_new(input_data, dst_size);
|
27
|
+
char* output_data = RSTRING_PTR(output);
|
28
|
+
size_t output_size = ZSTD_writeSkippableFrame((void*)output_data, dst_size, (const void*)skip_data, skip_size, magic_variant);
|
29
|
+
if (ZSTD_isError(output_size)) {
|
30
|
+
rb_raise(rb_eRuntimeError, "%s: %s", "write skippable frame failed", ZSTD_getErrorName(output_size));
|
31
|
+
}
|
32
|
+
|
33
|
+
rb_str_resize(output, output_size);
|
34
|
+
return output;
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE rb_read_skippable_frame(VALUE self, VALUE input_value)
|
38
|
+
{
|
39
|
+
char* input_data = RSTRING_PTR(input_value);
|
40
|
+
size_t input_size = RSTRING_LEN(input_value);
|
41
|
+
|
42
|
+
if (ZSTD_isSkippableFrame(input_data, input_size) == 0) {
|
43
|
+
return Qnil;
|
44
|
+
}
|
45
|
+
// ref https://github.com/facebook/zstd/blob/321490cd5b9863433b3d44816d04012874e5ecdb/tests/fuzzer.c#L2096
|
46
|
+
size_t const skipLen = 129 * 1024;
|
47
|
+
VALUE output = rb_str_new(NULL, skipLen);
|
48
|
+
char* output_data = RSTRING_PTR(output);
|
49
|
+
unsigned readMagic;
|
50
|
+
size_t output_size = ZSTD_readSkippableFrame((void*)output_data, skipLen, &readMagic, (const void*)input_data, input_size);
|
51
|
+
if (ZSTD_isError(output_size)) {
|
52
|
+
rb_raise(rb_eRuntimeError, "%s: %s", "read skippable frame failed", ZSTD_getErrorName(output_size));
|
53
|
+
}
|
54
|
+
rb_str_resize(output, output_size);
|
55
|
+
return output;
|
56
|
+
}
|
57
|
+
|
58
|
+
void
|
59
|
+
zstd_ruby_skippable_frame_init(void)
|
60
|
+
{
|
61
|
+
rb_define_module_function(rb_mZstd, "write_skippable_frame", rb_write_skippable_frame, -1);
|
62
|
+
rb_define_module_function(rb_mZstd, "read_skippable_frame", rb_read_skippable_frame, 1);
|
63
|
+
}
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zstd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- bin/setup
|
88
88
|
- ext/zstdruby/common.h
|
89
89
|
- ext/zstdruby/extconf.rb
|
90
|
+
- ext/zstdruby/libzstd/common/bits.h
|
90
91
|
- ext/zstdruby/libzstd/common/bitstream.h
|
91
92
|
- ext/zstdruby/libzstd/common/compiler.h
|
92
93
|
- ext/zstdruby/libzstd/common/cpu.h
|
@@ -155,6 +156,7 @@ files:
|
|
155
156
|
- ext/zstdruby/libzstd/zstd.h
|
156
157
|
- ext/zstdruby/libzstd/zstd_errors.h
|
157
158
|
- ext/zstdruby/main.c
|
159
|
+
- ext/zstdruby/skippable_frame.c
|
158
160
|
- ext/zstdruby/streaming_compress.c
|
159
161
|
- ext/zstdruby/streaming_compress.h
|
160
162
|
- ext/zstdruby/streaming_decompress.c
|
@@ -166,7 +168,7 @@ homepage: https://github.com/SpringMT/zstd-ruby
|
|
166
168
|
licenses:
|
167
169
|
- MIT
|
168
170
|
metadata: {}
|
169
|
-
post_install_message:
|
171
|
+
post_install_message:
|
170
172
|
rdoc_options: []
|
171
173
|
require_paths:
|
172
174
|
- lib
|
@@ -181,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
183
|
- !ruby/object:Gem::Version
|
182
184
|
version: '0'
|
183
185
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
186
|
+
rubygems_version: 3.3.26
|
187
|
+
signing_key:
|
186
188
|
specification_version: 4
|
187
189
|
summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
|
188
190
|
test_files: []
|