zstd-ruby 2.0.2 → 2.0.4
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 +4 -4
- data/README.md +0 -2
- data/ext/zstdruby/common.h +8 -2
- data/ext/zstdruby/ext-export.txt +1 -0
- data/ext/zstdruby/extconf.rb +27 -1
- data/ext/zstdruby/zstdruby.c +4 -3
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +4 -3
- /data/ext/zstdruby/{exports.txt → ext-export-with-ruby-abi-version.txt} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9a23c701181eccbc41191787fd658f9bc2d78a449468caff3b106b2bf64173e
|
|
4
|
+
data.tar.gz: addcdf88b39e425cf4090c9b461f33058c62c8ccd77404e70dd6674403c84db9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c340e8a040207bd0551a634bfe899f904276bb4ddc9e20b5148e888a978b5a4d9d88fcac92914d7fb31acf4e4ffd8345d60871709540d76f0bad9a06b27a2ea
|
|
7
|
+
data.tar.gz: e240f5870f6cd187012d52c181cbe8fdfd0b2a351b896c0d25832153b708e0b241c577153bf789cdf6b6beaafce66fa0d1901e6714b37c54573dcfce67842175
|
data/README.md
CHANGED
data/ext/zstdruby/common.h
CHANGED
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
extern VALUE rb_cCDict, rb_cDDict;
|
|
12
12
|
|
|
13
|
-
static int convert_compression_level(VALUE compression_level_value)
|
|
13
|
+
static int convert_compression_level(ZSTD_CCtx* ctx, VALUE compression_level_value)
|
|
14
14
|
{
|
|
15
15
|
if (NIL_P(compression_level_value)) {
|
|
16
16
|
return ZSTD_CLEVEL_DEFAULT;
|
|
17
17
|
}
|
|
18
|
+
if (!RB_INTEGER_TYPE_P(compression_level_value)) {
|
|
19
|
+
if (ctx) {
|
|
20
|
+
ZSTD_freeCCtx(ctx);
|
|
21
|
+
}
|
|
22
|
+
rb_raise(rb_eTypeError, "compression level must be an Integer");
|
|
23
|
+
}
|
|
18
24
|
return NUM2INT(compression_level_value);
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -28,7 +34,7 @@ static void set_compress_params(ZSTD_CCtx* const ctx, VALUE kwargs)
|
|
|
28
34
|
|
|
29
35
|
int compression_level = ZSTD_CLEVEL_DEFAULT;
|
|
30
36
|
if (kwargs_values[0] != Qundef && kwargs_values[0] != Qnil) {
|
|
31
|
-
compression_level = convert_compression_level(kwargs_values[0]);
|
|
37
|
+
compression_level = convert_compression_level(ctx, kwargs_values[0]);
|
|
32
38
|
}
|
|
33
39
|
ZSTD_CCtx_setParameter(ctx, ZSTD_c_compressionLevel, compression_level);
|
|
34
40
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_Init_zstdruby
|
data/ext/zstdruby/extconf.rb
CHANGED
|
@@ -2,12 +2,38 @@ require "mkmf"
|
|
|
2
2
|
|
|
3
3
|
have_func('rb_gc_mark_movable')
|
|
4
4
|
|
|
5
|
+
# Check if ruby_abi_version symbol is required
|
|
6
|
+
# Based on grpc's approach: https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/extconf.rb
|
|
7
|
+
def have_ruby_abi_version?
|
|
8
|
+
# Only development/preview versions need the symbol
|
|
9
|
+
return false if RUBY_PATCHLEVEL >= 0
|
|
10
|
+
|
|
11
|
+
# Ruby 3.2+ development versions require ruby_abi_version
|
|
12
|
+
major, minor = RUBY_VERSION.split('.').map(&:to_i)
|
|
13
|
+
if major > 3 || (major == 3 && minor >= 2)
|
|
14
|
+
puts "Ruby version #{RUBY_VERSION} >= 3.2. Using ruby_abi_version symbol."
|
|
15
|
+
return true
|
|
16
|
+
else
|
|
17
|
+
puts "Ruby version #{RUBY_VERSION} < 3.2. Not using ruby_abi_version symbol."
|
|
18
|
+
return false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Determine which export file to use based on Ruby version
|
|
23
|
+
def ext_export_filename
|
|
24
|
+
name = 'ext-export'
|
|
25
|
+
name += '-with-ruby-abi-version' if have_ruby_abi_version?
|
|
26
|
+
name
|
|
27
|
+
end
|
|
28
|
+
|
|
5
29
|
$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread -DDEBUGLEVEL=0 -fvisibility=hidden -DZSTDLIB_VISIBLE=\'__attribute__((visibility("hidden")))\' -DZSTDLIB_HIDDEN=\'__attribute__((visibility("hidden")))\''
|
|
6
30
|
$CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/
|
|
7
31
|
|
|
8
32
|
# macOS specific: Use exported_symbols_list to control symbol visibility
|
|
9
33
|
if RUBY_PLATFORM =~ /darwin/
|
|
10
|
-
|
|
34
|
+
ext_export_file = File.join(__dir__, "#{ext_export_filename}.txt")
|
|
35
|
+
$LDFLAGS += " -exported_symbols_list #{ext_export_file}"
|
|
36
|
+
puts "Using export file: #{ext_export_file}"
|
|
11
37
|
end
|
|
12
38
|
|
|
13
39
|
Dir.chdir File.expand_path('..', __FILE__) do
|
data/ext/zstdruby/zstdruby.c
CHANGED
|
@@ -14,6 +14,8 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
14
14
|
VALUE kwargs;
|
|
15
15
|
rb_scan_args(argc, argv, "10:", &input_value, &kwargs);
|
|
16
16
|
|
|
17
|
+
StringValue(input_value);
|
|
18
|
+
|
|
17
19
|
ZSTD_CCtx* const ctx = ZSTD_createCCtx();
|
|
18
20
|
if (ctx == NULL) {
|
|
19
21
|
rb_raise(rb_eRuntimeError, "%s", "ZSTD_createCCtx error");
|
|
@@ -21,7 +23,6 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
21
23
|
|
|
22
24
|
set_compress_params(ctx, kwargs);
|
|
23
25
|
|
|
24
|
-
StringValue(input_value);
|
|
25
26
|
char* input_data = RSTRING_PTR(input_value);
|
|
26
27
|
size_t input_size = RSTRING_LEN(input_value);
|
|
27
28
|
|
|
@@ -30,12 +31,12 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
30
31
|
char* output_data = RSTRING_PTR(output);
|
|
31
32
|
|
|
32
33
|
size_t const ret = zstd_compress(ctx, output_data, max_compressed_size, input_data, input_size, false);
|
|
34
|
+
ZSTD_freeCCtx(ctx);
|
|
33
35
|
if (ZSTD_isError(ret)) {
|
|
34
36
|
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
|
35
37
|
}
|
|
36
38
|
rb_str_resize(output, ret);
|
|
37
39
|
|
|
38
|
-
ZSTD_freeCCtx(ctx);
|
|
39
40
|
return output;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -169,7 +170,7 @@ static VALUE rb_cdict_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
169
170
|
VALUE dict;
|
|
170
171
|
VALUE compression_level_value;
|
|
171
172
|
rb_scan_args(argc, argv, "11", &dict, &compression_level_value);
|
|
172
|
-
int compression_level = convert_compression_level(compression_level_value);
|
|
173
|
+
int compression_level = convert_compression_level(NULL, compression_level_value);
|
|
173
174
|
|
|
174
175
|
StringValue(dict);
|
|
175
176
|
char* dict_buffer = RSTRING_PTR(dict);
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zstd-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SpringMT
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
10
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: bundler
|
|
@@ -99,7 +99,8 @@ files:
|
|
|
99
99
|
- bin/console
|
|
100
100
|
- bin/setup
|
|
101
101
|
- ext/zstdruby/common.h
|
|
102
|
-
- ext/zstdruby/
|
|
102
|
+
- ext/zstdruby/ext-export-with-ruby-abi-version.txt
|
|
103
|
+
- ext/zstdruby/ext-export.txt
|
|
103
104
|
- ext/zstdruby/extconf.rb
|
|
104
105
|
- ext/zstdruby/libzstd/common/allocations.h
|
|
105
106
|
- ext/zstdruby/libzstd/common/bits.h
|
|
File without changes
|