diff --git a/crates/rb-sys-tests/src/stable_api_test.rs b/crates/rb-sys-tests/src/stable_api_test.rs index 349c5e44..8c3156ca 100644 --- a/crates/rb-sys-tests/src/stable_api_test.rs +++ b/crates/rb-sys-tests/src/stable_api_test.rs @@ -652,6 +652,6 @@ parity_test!( name: test_rb_thread_sleep, func: thread_sleep, data_factory: { - std::time::Duration::from_secs(1) + std::time::Duration::from_millis(100) } ); diff --git a/crates/rb-sys/src/stable_api.rs b/crates/rb-sys/src/stable_api.rs index 4c7b37c2..10b34f9c 100644 --- a/crates/rb-sys/src/stable_api.rs +++ b/crates/rb-sys/src/stable_api.rs @@ -14,7 +14,8 @@ use crate::VALUE; use std::{ os::raw::{c_char, c_long}, - ptr::NonNull, time::Duration, + ptr::NonNull, + time::Duration, }; pub trait StableApiDefinition { diff --git a/crates/rb-sys/src/stable_api/compiled.rs b/crates/rb-sys/src/stable_api/compiled.rs index 5057b003..527fabd0 100644 --- a/crates/rb-sys/src/stable_api/compiled.rs +++ b/crates/rb-sys/src/stable_api/compiled.rs @@ -203,14 +203,14 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, tv_usec: microseconds, }; - + unsafe { impl_thread_sleep(time) } - } + } } diff --git a/crates/rb-sys/src/stable_api/ruby_2_6.rs b/crates/rb-sys/src/stable_api/ruby_2_6.rs index 517a433f..0407f8d7 100644 --- a/crates/rb-sys/src/stable_api/ruby_2_6.rs +++ b/crates/rb-sys/src/stable_api/ruby_2_6.rs @@ -104,7 +104,7 @@ impl StableApiDefinition for Definition { if self.special_const_p(obj) { true } else { - let rbasic = obj as *const crate::Rbasic; + let rbasic = obj as *const crate::RBasic; ((*rbasic).flags & crate::ruby_fl_type::RUBY_FL_FREEZE as VALUE) != 0 } } @@ -266,8 +266,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, diff --git a/crates/rb-sys/src/stable_api/ruby_2_7.rs b/crates/rb-sys/src/stable_api/ruby_2_7.rs index 96e96861..e5a1eb12 100644 --- a/crates/rb-sys/src/stable_api/ruby_2_7.rs +++ b/crates/rb-sys/src/stable_api/ruby_2_7.rs @@ -266,8 +266,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, diff --git a/crates/rb-sys/src/stable_api/ruby_3_0.rs b/crates/rb-sys/src/stable_api/ruby_3_0.rs index f96330f0..cd22ae7a 100644 --- a/crates/rb-sys/src/stable_api/ruby_3_0.rs +++ b/crates/rb-sys/src/stable_api/ruby_3_0.rs @@ -274,8 +274,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, diff --git a/crates/rb-sys/src/stable_api/ruby_3_1.rs b/crates/rb-sys/src/stable_api/ruby_3_1.rs index f9220646..a604426f 100644 --- a/crates/rb-sys/src/stable_api/ruby_3_1.rs +++ b/crates/rb-sys/src/stable_api/ruby_3_1.rs @@ -267,8 +267,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, diff --git a/crates/rb-sys/src/stable_api/ruby_3_2.rs b/crates/rb-sys/src/stable_api/ruby_3_2.rs index 3127b520..52e0067e 100644 --- a/crates/rb-sys/src/stable_api/ruby_3_2.rs +++ b/crates/rb-sys/src/stable_api/ruby_3_2.rs @@ -265,8 +265,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, diff --git a/crates/rb-sys/src/stable_api/ruby_3_3.rs b/crates/rb-sys/src/stable_api/ruby_3_3.rs index bae77096..d068fac1 100644 --- a/crates/rb-sys/src/stable_api/ruby_3_3.rs +++ b/crates/rb-sys/src/stable_api/ruby_3_3.rs @@ -258,14 +258,14 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds, tv_usec: microseconds, }; - + unsafe { crate::rb_thread_wait_for(time) } } } diff --git a/crates/rb-sys/src/stable_api/ruby_3_4.rs b/crates/rb-sys/src/stable_api/ruby_3_4.rs index 93dca507..74a82f5b 100644 --- a/crates/rb-sys/src/stable_api/ruby_3_4.rs +++ b/crates/rb-sys/src/stable_api/ruby_3_4.rs @@ -258,8 +258,8 @@ impl StableApiDefinition for Definition { #[inline] fn thread_sleep(&self, duration: Duration) { - let seconds = duration.as_secs() as i64; - let microseconds = duration.subsec_micros() as i64; + let seconds = duration.as_secs() as _; + let microseconds = duration.subsec_micros() as _; let time = crate::timeval { tv_sec: seconds,