itsi-server 0.2.21 → 0.2.22

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +25 -38
  3. data/Cargo.toml +4 -0
  4. data/Rakefile +39 -7
  5. data/ext/itsi_scheduler/Cargo.toml +1 -1
  6. data/ext/itsi_server/Cargo.toml +1 -1
  7. data/ext/itsi_server/src/server/signal.rs +7 -5
  8. data/lib/itsi/server/native_extension.rb +34 -0
  9. data/lib/itsi/server/version.rb +1 -1
  10. data/lib/itsi/server.rb +10 -2
  11. data/vendor/rb-sys-build/.cargo-ok +1 -0
  12. data/vendor/rb-sys-build/.cargo_vcs_info.json +6 -0
  13. data/vendor/rb-sys-build/Cargo.lock +294 -0
  14. data/vendor/rb-sys-build/Cargo.toml +71 -0
  15. data/vendor/rb-sys-build/Cargo.toml.orig +32 -0
  16. data/vendor/rb-sys-build/LICENSE-APACHE +190 -0
  17. data/vendor/rb-sys-build/LICENSE-MIT +21 -0
  18. data/vendor/rb-sys-build/src/bindings/sanitizer.rs +185 -0
  19. data/vendor/rb-sys-build/src/bindings/stable_api.rs +247 -0
  20. data/vendor/rb-sys-build/src/bindings/wrapper.h +71 -0
  21. data/vendor/rb-sys-build/src/bindings.rs +280 -0
  22. data/vendor/rb-sys-build/src/cc.rs +421 -0
  23. data/vendor/rb-sys-build/src/lib.rs +12 -0
  24. data/vendor/rb-sys-build/src/rb_config/flags.rs +101 -0
  25. data/vendor/rb-sys-build/src/rb_config/library.rs +132 -0
  26. data/vendor/rb-sys-build/src/rb_config/search_path.rs +57 -0
  27. data/vendor/rb-sys-build/src/rb_config.rs +906 -0
  28. data/vendor/rb-sys-build/src/utils.rs +53 -0
  29. metadata +25 -11
  30. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/common.rs +0 -355
  31. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/dynamic.rs +0 -276
  32. data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/macros.rs +0 -49
  33. data/ext/itsi_server/target/release/build/oid-registry-71b994a322b296ec/out/oid_db.rs +0 -537
  34. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-2.7.8.rs +0 -6234
  35. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-3.4.5.rs +0 -8936
  36. data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-4.0.1.rs +0 -9060
  37. data/ext/itsi_server/target/release/build/typenum-11265e44e46de3b7/out/tests.rs +0 -20563
@@ -0,0 +1,71 @@
1
+ #include "ruby.h"
2
+
3
+ #ifdef HAVE_RUBY_DEBUG_H
4
+ #include "ruby/debug.h"
5
+ #endif
6
+ #ifdef HAVE_RUBY_DEFINES_H
7
+ #include "ruby/defines.h"
8
+ #endif
9
+ #ifdef HAVE_RUBY_ENCODING_H
10
+ #include "ruby/encoding.h"
11
+ #endif
12
+ #ifdef HAVE_RUBY_FIBER_SCHEDULER_H
13
+ #include "ruby/fiber/scheduler.h"
14
+ #endif
15
+ #ifdef HAVE_RUBY_INTERN_H
16
+ #include "ruby/intern.h"
17
+ #endif
18
+ #ifdef HAVE_RUBY_IO_H
19
+ #include "ruby/io.h"
20
+ #endif
21
+ #ifdef HAVE_RUBY_MEMORY_VIEW_H
22
+ #include "ruby/memory_view.h"
23
+ #endif
24
+ #ifdef HAVE_RUBY_MISSING_H
25
+ #include "ruby/missing.h"
26
+ #endif
27
+ #ifdef HAVE_RUBY_ONIGMO_H
28
+ #include "ruby/onigmo.h"
29
+ #endif
30
+ #ifdef HAVE_RUBY_ONIGURUMA_H
31
+ #include "ruby/oniguruma.h"
32
+ #endif
33
+ #ifdef HAVE_RUBY_RACTOR_H
34
+ #include "ruby/ractor.h"
35
+ #endif
36
+ #ifdef HAVE_RUBY_RANDOM_H
37
+ #include "ruby/random.h"
38
+ #endif
39
+ #ifdef HAVE_RUBY_RE_H
40
+ #include "ruby/re.h"
41
+ #endif
42
+ #ifdef HAVE_RUBY_REGEX_H
43
+ #include "ruby/regex.h"
44
+ #endif
45
+ #ifdef HAVE_RUBY_RUBY_H
46
+ #include "ruby/ruby.h"
47
+ #endif
48
+ #ifdef HAVE_RUBY_ST_H
49
+ #include "ruby/st.h"
50
+ #endif
51
+ #ifdef HAVE_RUBY_THREAD_H
52
+ #include "ruby/thread.h"
53
+ #endif
54
+ #ifdef HAVE_RUBY_THREAD_NATIVE_H
55
+ #include "ruby/thread_native.h"
56
+ #endif
57
+ #ifdef HAVE_RUBY_UTIL_H
58
+ #include "ruby/util.h"
59
+ #endif
60
+ #ifdef HAVE_RUBY_VERSION_H
61
+ #include "ruby/version.h"
62
+ #endif
63
+ #ifdef HAVE_RUBY_VM_H
64
+ #include "ruby/vm.h"
65
+ #endif
66
+ #ifdef HAVE_RUBY_WIN32_H
67
+ #include "ruby/win32.h"
68
+ #endif
69
+ #ifdef HAVE_RUBY_IO_BUFFER_H
70
+ #include "ruby/io/buffer.h"
71
+ #endif
@@ -0,0 +1,280 @@
1
+ mod sanitizer;
2
+ mod stable_api;
3
+
4
+ use crate::cc::Build;
5
+ use crate::utils::is_msvc;
6
+ use crate::{debug_log, RbConfig};
7
+ use quote::ToTokens;
8
+ use stable_api::{categorize_bindings, opaqueify_bindings};
9
+ use std::fs::File;
10
+ use std::io::Write;
11
+ use std::path::{Path, PathBuf};
12
+ use std::{env, error::Error};
13
+ use syn::{Expr, ExprLit, ItemConst, Lit};
14
+
15
+ const WRAPPER_H_CONTENT: &str = include_str!("bindings/wrapper.h");
16
+
17
+ /// Generate bindings for the Ruby using bindgen.
18
+ pub fn generate(
19
+ rbconfig: &RbConfig,
20
+ static_ruby: bool,
21
+ cfg_out: &mut File,
22
+ ) -> Result<PathBuf, Box<dyn Error>> {
23
+ let out_dir = PathBuf::from(env::var("OUT_DIR")?);
24
+
25
+ let mut clang_args = vec![];
26
+ if let Some(ruby_include_dir) = rbconfig.get("rubyhdrdir") {
27
+ clang_args.push(format!("-I{}", ruby_include_dir));
28
+ }
29
+ if let Some(ruby_arch_include_dir) = rbconfig.get("rubyarchhdrdir") {
30
+ clang_args.push(format!("-I{}", ruby_arch_include_dir));
31
+ }
32
+
33
+ clang_args.extend(Build::default_cflags());
34
+ clang_args.extend(rbconfig.cflags.clone());
35
+ clang_args.extend(rbconfig.cppflags());
36
+
37
+ // On Windows x86_64, we need to handle AVX512 FP16 compatibility issues
38
+ // Clang 20+ includes types like __m512h that aren't compatible with bindgen
39
+ if cfg!(target_os = "windows") && cfg!(target_arch = "x86_64") {
40
+ // For MinGW toolchain, disable SSE/AVX only for bindgen
41
+ // This prevents intrinsics headers from loading but doesn't affect the final binary
42
+ if !is_msvc() {
43
+ clang_args.push("-mno-sse".to_string());
44
+ clang_args.push("-mno-avx".to_string());
45
+ }
46
+ }
47
+
48
+ debug_log!("INFO: using bindgen with clang args: {:?}", clang_args);
49
+
50
+ let mut wrapper_h = WRAPPER_H_CONTENT.to_string();
51
+
52
+ if !is_msvc() {
53
+ wrapper_h.push_str("#ifdef HAVE_RUBY_ATOMIC_H\n");
54
+ wrapper_h.push_str("#include \"ruby/atomic.h\"\n");
55
+ wrapper_h.push_str("#endif\n");
56
+ }
57
+
58
+ if rbconfig.have_ruby_header("ruby/io/buffer.h") {
59
+ clang_args.push("-DHAVE_RUBY_IO_BUFFER_H".to_string());
60
+ }
61
+
62
+ let bindings = default_bindgen(clang_args, rbconfig)
63
+ .allowlist_file(".*ruby.*")
64
+ .blocklist_item("ruby_abi_version")
65
+ .blocklist_function("rb_tr_abi_version")
66
+ .blocklist_function("^__.*")
67
+ .blocklist_item("RData")
68
+ .blocklist_function("rb_tr_rdata")
69
+ .blocklist_function("rb_tr_rtypeddata")
70
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()));
71
+
72
+ let bindings = if cfg!(feature = "bindgen-rbimpls") {
73
+ bindings
74
+ } else {
75
+ bindings
76
+ .blocklist_item("^rbimpl_.*")
77
+ .blocklist_item("^RBIMPL_.*")
78
+ };
79
+
80
+ let bindings = if cfg!(feature = "bindgen-deprecated-types") {
81
+ bindings
82
+ } else {
83
+ bindings.blocklist_item("^_bindgen_ty_9.*")
84
+ };
85
+
86
+ let bindings = opaqueify_bindings(rbconfig, bindings, &mut wrapper_h);
87
+
88
+ let mut tokens = {
89
+ write!(std::io::stderr(), "{}", wrapper_h)?;
90
+ let bindings = bindings.header_contents("wrapper.h", &wrapper_h);
91
+ let code_string = bindings.generate()?.to_string();
92
+ syn::parse_file(&code_string)?
93
+ };
94
+
95
+ let slug = rbconfig.ruby_version_slug();
96
+ let crate_version = env!("CARGO_PKG_VERSION");
97
+ let out_path = out_dir.join(format!("bindings-{}-{}.rs", crate_version, slug));
98
+
99
+ let code = {
100
+ sanitizer::ensure_backwards_compatible_encoding_pointers(&mut tokens);
101
+ clean_docs(rbconfig, &mut tokens);
102
+
103
+ if is_msvc() {
104
+ qualify_symbols_for_msvc(&mut tokens, static_ruby, rbconfig);
105
+ }
106
+
107
+ push_cargo_cfg_from_bindings(&tokens, cfg_out)?;
108
+ categorize_bindings(&mut tokens);
109
+ tokens.into_token_stream().to_string()
110
+ };
111
+
112
+ let mut out_file = File::create(&out_path)?;
113
+ std::io::Write::write_all(&mut out_file, code.as_bytes())?;
114
+ run_rustfmt(&out_path);
115
+
116
+ Ok(out_path)
117
+ }
118
+
119
+ fn run_rustfmt(path: &Path) {
120
+ let mut cmd = std::process::Command::new("rustfmt");
121
+ cmd.stderr(std::process::Stdio::inherit());
122
+ cmd.stdout(std::process::Stdio::inherit());
123
+
124
+ cmd.arg(path);
125
+
126
+ if let Err(e) = cmd.status() {
127
+ debug_log!("WARN: failed to run rustfmt: {}", e);
128
+ }
129
+ }
130
+
131
+ fn clean_docs(rbconfig: &RbConfig, syntax: &mut syn::File) {
132
+ if rbconfig.is_cross_compiling() {
133
+ return;
134
+ }
135
+
136
+ let ver = rbconfig.ruby_version_slug();
137
+
138
+ sanitizer::cleanup_docs(syntax, &ver).unwrap_or_else(|e| {
139
+ debug_log!("WARN: failed to clean up docs, skipping: {}", e);
140
+ })
141
+ }
142
+
143
+ fn default_bindgen(clang_args: Vec<String>, _rbconfig: &RbConfig) -> bindgen::Builder {
144
+ // Disable layout tests and Debug impl on Windows MinGW due to packed struct layout incompatibilities
145
+ let is_windows_mingw = cfg!(target_os = "windows") && !is_msvc();
146
+
147
+ let enable_layout_tests = !is_windows_mingw && cfg!(feature = "bindgen-layout-tests");
148
+ let impl_debug = !is_windows_mingw && cfg!(feature = "bindgen-impl-debug");
149
+
150
+ let mut bindings = bindgen::Builder::default()
151
+ .rustified_enum(".*")
152
+ .no_copy("rb_data_type_struct")
153
+ .derive_eq(true)
154
+ .derive_debug(true)
155
+ .clang_args(clang_args)
156
+ .layout_tests(enable_layout_tests)
157
+ .blocklist_item("^__darwin_pthread.*")
158
+ .blocklist_item("^_opaque_pthread.*")
159
+ .blocklist_item("^__pthread_.*")
160
+ .blocklist_item("^pthread_.*")
161
+ .blocklist_item("^rb_native.*")
162
+ .blocklist_type("INET_PORT_RESERVATION_INSTANCE")
163
+ .blocklist_type("PINET_PORT_RESERVATION_INSTANCE")
164
+ .opaque_type("^__sFILE$")
165
+ .merge_extern_blocks(true)
166
+ .generate_comments(true)
167
+ .size_t_is_usize(env::var("CARGO_FEATURE_BINDGEN_SIZE_T_IS_USIZE").is_ok())
168
+ .impl_debug(impl_debug)
169
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()));
170
+
171
+ // Make __mingw_ldbl_type_t opaque on Windows MinGW to avoid conflicting packed/align representation
172
+ if cfg!(target_os = "windows") && !is_msvc() {
173
+ bindings = bindings.opaque_type("__mingw_ldbl_type_t");
174
+ }
175
+
176
+ if env::var("CARGO_FEATURE_BINDGEN_ENABLE_FUNCTION_ATTRIBUTE_DETECTION").is_ok() {
177
+ bindings.enable_function_attribute_detection()
178
+ } else {
179
+ bindings
180
+ }
181
+ }
182
+
183
+ // This is needed because bindgen doesn't support the `__declspec(dllimport)` on
184
+ // global variables. Without it, symbols are not found.
185
+ // See https://stackoverflow.com/a/66182704/2057700
186
+ fn qualify_symbols_for_msvc(tokens: &mut syn::File, is_static: bool, rbconfig: &RbConfig) {
187
+ let kind = if is_static { "static" } else { "dylib" };
188
+
189
+ let name = if is_static {
190
+ rbconfig.libruby_static_name()
191
+ } else {
192
+ rbconfig.libruby_so_name()
193
+ };
194
+
195
+ sanitizer::add_link_ruby_directives(tokens, &name, kind).unwrap_or_else(|e| {
196
+ debug_log!("WARN: failed to add link directives: {}", e);
197
+ });
198
+ }
199
+
200
+ // Add things like `#[cfg(ruby_use_transient_heap = "true")]` to the bindings config
201
+ fn push_cargo_cfg_from_bindings(
202
+ syntax: &syn::File,
203
+ cfg_out: &mut File,
204
+ ) -> Result<(), Box<dyn Error>> {
205
+ fn is_defines(line: &str) -> bool {
206
+ line.starts_with("HAVE_RUBY")
207
+ || line.starts_with("HAVE_RB")
208
+ || line.starts_with("USE")
209
+ || line.starts_with("RUBY_DEBUG")
210
+ || line.starts_with("RUBY_NDEBUG")
211
+ }
212
+
213
+ for item in syntax.items.iter() {
214
+ if let syn::Item::Const(item) = item {
215
+ let conf = ConfValue::new(item);
216
+ let conf_name = conf.name();
217
+
218
+ if is_defines(&conf_name) {
219
+ let name = conf_name.to_lowercase();
220
+ let val = conf.value_bool().to_string();
221
+ println!(
222
+ r#"cargo:rustc-check-cfg=cfg(ruby_{}, values("true", "false"))"#,
223
+ name
224
+ );
225
+ println!("cargo:rustc-cfg=ruby_{}=\"{}\"", name, val);
226
+ println!("cargo:defines_{}={}", name, val);
227
+ writeln!(cfg_out, "cargo:defines_{}={}", name, val)?;
228
+ }
229
+
230
+ if conf_name.starts_with("RUBY_ABI_VERSION") {
231
+ println!("cargo:ruby_abi_version={}", conf.value_string());
232
+ writeln!(cfg_out, "cargo:ruby_abi_version={}", conf.value_string())?;
233
+ }
234
+ }
235
+ }
236
+
237
+ Ok(())
238
+ }
239
+
240
+ /// An autoconf constant in the bindings
241
+ struct ConfValue<'a> {
242
+ item: &'a syn::ItemConst,
243
+ }
244
+
245
+ impl<'a> ConfValue<'a> {
246
+ pub fn new(item: &'a ItemConst) -> Self {
247
+ Self { item }
248
+ }
249
+
250
+ pub fn name(&self) -> String {
251
+ self.item.ident.to_string()
252
+ }
253
+
254
+ pub fn value_string(&self) -> String {
255
+ match &*self.item.expr {
256
+ Expr::Lit(ExprLit { lit, .. }) => lit.to_token_stream().to_string(),
257
+ _ => panic!(
258
+ "Could not convert HAVE_* constant to string: {:#?}",
259
+ self.item
260
+ ),
261
+ }
262
+ }
263
+
264
+ pub fn value_bool(&self) -> bool {
265
+ match &*self.item.expr {
266
+ Expr::Lit(ExprLit {
267
+ lit: Lit::Int(ref lit),
268
+ ..
269
+ }) => lit.base10_parse::<u8>().unwrap_or(1) != 0,
270
+ Expr::Lit(ExprLit {
271
+ lit: Lit::Bool(ref lit),
272
+ ..
273
+ }) => lit.value,
274
+ _ => panic!(
275
+ "Could not convert HAVE_* constant to bool: {:#?}",
276
+ self.item
277
+ ),
278
+ }
279
+ }
280
+ }