blake3-rb 1.5.4.1 → 1.5.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79bfa02f801439d4336e9cc5d1c6f66b3fea5ee900fa327c98a76006289610cb
4
- data.tar.gz: a84aff893fc9fb311103464071c2628fe398feb370f8afb2092c8a72663fd473
3
+ metadata.gz: 6434507643a1bd262f562044a1a022c3ffd4348e82a217dde88ee360036c69cd
4
+ data.tar.gz: 0bd45e1cecd30ed52d4358961397a4c11997bbdf00dced6df48958e77756476d
5
5
  SHA512:
6
- metadata.gz: f55aad4696d2c13f956472e3193c68501fef7f1a698d86757bb251d533c6a44d2799d24842053e49ddab0f2ca01462d34583daf8fd9a61513a0341ac0bfde95c
7
- data.tar.gz: 06ffcdbc95270b3ae7b3b7a9ff242cd5cb9388aef94d8e7fcfc669d24e357d2913b09f1566eb24785c55e39044fa971c342eb97dfee343f16bc8161e13434e06
6
+ metadata.gz: c45295e7fec2446bb51925c42674a340a5db9155ea4f0b7f280b49b29e4728c15e91b8017ce99f0f358d42a4cf48e09db12c98b3205999429707a82de7ac3ea1
7
+ data.tar.gz: 7e690b4cc449d9289f84919614187ccd7b9f2a226b4264c00e507847e43586b049182d0c80fc9d489311d4d78c5fdbdba90ae84307f3d123e282a6b09c02c8ea
@@ -3,4 +3,23 @@
3
3
  require "mkmf"
4
4
  require "rb_sys/mkmf"
5
5
 
6
- create_rust_makefile("digest/blake3/blake3_ext")
6
+ # Detect when DIGEST_USE_RB_EXT_RESOLVE_SYMBOL is defined truthy,
7
+ # which indicates rb_ext_resolve_symbol("digest.so", "rb_digest_wrap_metadata")
8
+ # will work with the version of Digest we're building against.
9
+ digest_use_rb_ext_resolve_symbol = try_compile(<<~C)
10
+ #include <ruby/digest.h>
11
+
12
+ #if !defined(DIGEST_USE_RB_EXT_RESOLVE_SYMBOL)
13
+ # error DIGEST_USE_RB_EXT_RESOLVE_SYMBOL not defined
14
+ #endif
15
+ #if !DIGEST_USE_RB_EXT_RESOLVE_SYMBOL
16
+ # error DIGEST_USE_RB_EXT_RESOLVE_SYMBOL is 0
17
+ #endif
18
+ C
19
+ puts("digest_use_rb_ext_resolve_symbol=#{digest_use_rb_ext_resolve_symbol}")
20
+
21
+ create_rust_makefile("digest/blake3/blake3_ext") do |r|
22
+ if digest_use_rb_ext_resolve_symbol
23
+ r.extra_rustflags = ["--cfg digest_use_rb_ext_resolve_symbol"]
24
+ end
25
+ end
@@ -1,7 +1,6 @@
1
+ use rb_sys::{size_t, VALUE};
1
2
  use std::ffi::{c_int, c_uchar, c_void};
2
3
 
3
- use rb_sys::{rb_data_object_wrap, rb_obj_freeze, size_t, VALUE};
4
-
5
4
  pub const RUBY_DIGEST_API_VERSION: c_int = 3;
6
5
 
7
6
  pub type RbDigestHashInitFuncT = unsafe extern "C" fn(*mut c_void) -> c_int;
@@ -20,7 +19,40 @@ pub struct RbDigestMetadataT {
20
19
  pub finish_func: RbDigestHashFinishFuncT,
21
20
  }
22
21
 
22
+ #[cfg(digest_use_rb_ext_resolve_symbol)]
23
+ pub unsafe fn rb_digest_make_metadata(meta: &'static RbDigestMetadataT) -> VALUE {
24
+ static mut WRAPPER: Option<unsafe extern "C" fn(&'static RbDigestMetadataT) -> VALUE> = None;
25
+
26
+ unsafe fn load_wrapper() {
27
+ use rb_sys::rb_ext_resolve_symbol;
28
+ use std::ffi::c_char;
29
+ use std::sync::Once;
30
+
31
+ static INIT: Once = Once::new();
32
+
33
+ INIT.call_once(|| {
34
+ let lib_name = "digest.so\0".as_ptr() as *const c_char;
35
+ let symbol_name = "rb_digest_wrap_metadata\0".as_ptr() as *const c_char;
36
+ let symbol_ptr = rb_ext_resolve_symbol(lib_name, symbol_name);
37
+
38
+ if !symbol_ptr.is_null() {
39
+ WRAPPER = Some(std::mem::transmute(symbol_ptr));
40
+ } else {
41
+ panic!("Failed to resolve rb_digest_wrap_metadata");
42
+ }
43
+ });
44
+ }
45
+
46
+ load_wrapper();
47
+ if let Some(wrapper) = WRAPPER {
48
+ return wrapper(meta);
49
+ }
50
+ panic!("Failed to resolve rb_digest_wrap_metadata");
51
+ }
52
+
53
+ #[cfg(not(digest_use_rb_ext_resolve_symbol))]
23
54
  pub unsafe fn rb_digest_make_metadata(meta: &'static RbDigestMetadataT) -> VALUE {
55
+ use rb_sys::{rb_data_object_wrap, rb_obj_freeze};
24
56
  let data = rb_data_object_wrap(
25
57
  0 as VALUE,
26
58
  meta as *const RbDigestMetadataT as *mut c_void,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blake3-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4.1
4
+ version: 1.5.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.4.19
67
+ rubygems_version: 3.5.3
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Blake3 hash function bindings for Ruby.