zstd-ruby 1.5.2.3 → 1.5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -5
  3. data/ext/zstdruby/extconf.rb +1 -1
  4. data/ext/zstdruby/libzstd/common/allocations.h +55 -0
  5. data/ext/zstdruby/libzstd/common/bits.h +200 -0
  6. data/ext/zstdruby/libzstd/common/bitstream.h +19 -60
  7. data/ext/zstdruby/libzstd/common/compiler.h +26 -3
  8. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  9. data/ext/zstdruby/libzstd/common/debug.c +1 -1
  10. data/ext/zstdruby/libzstd/common/debug.h +1 -1
  11. data/ext/zstdruby/libzstd/common/entropy_common.c +12 -40
  12. data/ext/zstdruby/libzstd/common/error_private.c +9 -2
  13. data/ext/zstdruby/libzstd/common/error_private.h +1 -1
  14. data/ext/zstdruby/libzstd/common/fse.h +5 -83
  15. data/ext/zstdruby/libzstd/common/fse_decompress.c +7 -99
  16. data/ext/zstdruby/libzstd/common/huf.h +65 -156
  17. data/ext/zstdruby/libzstd/common/mem.h +39 -46
  18. data/ext/zstdruby/libzstd/common/pool.c +26 -10
  19. data/ext/zstdruby/libzstd/common/pool.h +7 -1
  20. data/ext/zstdruby/libzstd/common/portability_macros.h +22 -3
  21. data/ext/zstdruby/libzstd/common/threading.c +68 -14
  22. data/ext/zstdruby/libzstd/common/threading.h +5 -10
  23. data/ext/zstdruby/libzstd/common/xxhash.c +2 -2
  24. data/ext/zstdruby/libzstd/common/xxhash.h +8 -8
  25. data/ext/zstdruby/libzstd/common/zstd_common.c +1 -36
  26. data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
  27. data/ext/zstdruby/libzstd/common/zstd_internal.h +17 -118
  28. data/ext/zstdruby/libzstd/common/zstd_trace.h +3 -3
  29. data/ext/zstdruby/libzstd/compress/clevels.h +1 -1
  30. data/ext/zstdruby/libzstd/compress/fse_compress.c +7 -124
  31. data/ext/zstdruby/libzstd/compress/hist.c +1 -1
  32. data/ext/zstdruby/libzstd/compress/hist.h +1 -1
  33. data/ext/zstdruby/libzstd/compress/huf_compress.c +234 -169
  34. data/ext/zstdruby/libzstd/compress/zstd_compress.c +1243 -538
  35. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +225 -151
  36. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +115 -39
  37. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -8
  38. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +3 -3
  39. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
  40. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
  41. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
  42. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +128 -62
  43. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +95 -33
  44. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
  45. data/ext/zstdruby/libzstd/compress/zstd_fast.c +433 -148
  46. data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
  47. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +398 -345
  48. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +4 -2
  49. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -5
  50. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -1
  51. data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
  52. data/ext/zstdruby/libzstd/compress/zstd_opt.c +106 -80
  53. data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
  54. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +17 -9
  55. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +1 -1
  56. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +434 -441
  57. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +30 -39
  58. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +4 -4
  59. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
  60. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +205 -80
  61. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +201 -81
  62. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +6 -1
  63. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +4 -2
  64. data/ext/zstdruby/libzstd/dictBuilder/cover.c +19 -15
  65. data/ext/zstdruby/libzstd/dictBuilder/cover.h +1 -1
  66. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +2 -2
  67. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +11 -89
  68. data/ext/zstdruby/libzstd/zdict.h +53 -31
  69. data/ext/zstdruby/libzstd/zstd.h +580 -135
  70. data/ext/zstdruby/libzstd/zstd_errors.h +27 -8
  71. data/ext/zstdruby/main.c +6 -0
  72. data/ext/zstdruby/skippable_frame.c +63 -0
  73. data/lib/zstd-ruby/version.rb +1 -1
  74. metadata +9 -6
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) Yann Collet, Facebook, Inc.
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 ZSTDERRORLIB_VISIBILITY
24
- # if defined(__GNUC__) && (__GNUC__ >= 4)
25
- # define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
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 ZSTDERRORLIB_VISIBILITY
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) ZSTDERRORLIB_VISIBILITY
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) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
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 ZSTDERRORLIB_VISIBILITY
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
+ }
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "1.5.2.3"
2
+ VERSION = "1.5.5.0"
3
3
  end
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.2.3
4
+ version: 1.5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SpringMT
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-23 00:00:00.000000000 Z
11
+ date: 2023-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,8 @@ files:
87
87
  - bin/setup
88
88
  - ext/zstdruby/common.h
89
89
  - ext/zstdruby/extconf.rb
90
+ - ext/zstdruby/libzstd/common/allocations.h
91
+ - ext/zstdruby/libzstd/common/bits.h
90
92
  - ext/zstdruby/libzstd/common/bitstream.h
91
93
  - ext/zstdruby/libzstd/common/compiler.h
92
94
  - ext/zstdruby/libzstd/common/cpu.h
@@ -155,6 +157,7 @@ files:
155
157
  - ext/zstdruby/libzstd/zstd.h
156
158
  - ext/zstdruby/libzstd/zstd_errors.h
157
159
  - ext/zstdruby/main.c
160
+ - ext/zstdruby/skippable_frame.c
158
161
  - ext/zstdruby/streaming_compress.c
159
162
  - ext/zstdruby/streaming_compress.h
160
163
  - ext/zstdruby/streaming_decompress.c
@@ -166,7 +169,7 @@ homepage: https://github.com/SpringMT/zstd-ruby
166
169
  licenses:
167
170
  - MIT
168
171
  metadata: {}
169
- post_install_message:
172
+ post_install_message:
170
173
  rdoc_options: []
171
174
  require_paths:
172
175
  - lib
@@ -181,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
184
  - !ruby/object:Gem::Version
182
185
  version: '0'
183
186
  requirements: []
184
- rubygems_version: 3.1.6
185
- signing_key:
187
+ rubygems_version: 3.3.26
188
+ signing_key:
186
189
  specification_version: 4
187
190
  summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
188
191
  test_files: []