diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-10-24 15:52:37 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-10-24 15:53:53 +0200 |
commit | 148961adcd0704d964fce920330a6301b9704c25 (patch) | |
tree | 1f1f0cb7326775788683c77f0e2cceb495d3cc95 /spec/ruby/optional | |
parent | 342fbae83c2e80d1b49656bc7c689cc7fe8980ce (diff) | |
download | ruby-148961adcd0704d964fce920330a6301b9704c25.tar.gz |
Update to ruby/spec@4f59d86
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r-- | spec/ruby/optional/capi/ext/thread_spec.c | 9 | ||||
-rw-r--r-- | spec/ruby/optional/capi/thread_spec.rb | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/ext/thread_spec.c b/spec/ruby/optional/capi/ext/thread_spec.c index 743828b523..53eae456b2 100644 --- a/spec/ruby/optional/capi/ext/thread_spec.c +++ b/spec/ruby/optional/capi/ext/thread_spec.c @@ -73,6 +73,14 @@ static void* blocking_gvl_func_for_udf_io(void *data) { } } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +static VALUE thread_spec_rb_thread_call_without_gvl_native_function(VALUE self) { + pid_t ret = (pid_t) (long) rb_thread_call_without_gvl((void *(*)(void *)) getpid, 0, RUBY_UBF_IO, 0); + return LONG2FIX(ret); +} +#pragma GCC diagnostic pop + /* Returns true if the thread is interrupted. */ static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) { int fds[2]; @@ -134,6 +142,7 @@ void Init_thread_spec(void) { VALUE cls = rb_define_class("CApiThreadSpecs", rb_cObject); rb_define_method(cls, "rb_thread_alone", thread_spec_rb_thread_alone, 0); rb_define_method(cls, "rb_thread_call_without_gvl", thread_spec_rb_thread_call_without_gvl, 0); + rb_define_method(cls, "rb_thread_call_without_gvl_native_function", thread_spec_rb_thread_call_without_gvl_native_function, 0); rb_define_method(cls, "rb_thread_call_without_gvl_with_ubf_io", thread_spec_rb_thread_call_without_gvl_with_ubf_io, 0); rb_define_method(cls, "rb_thread_current", thread_spec_rb_thread_current, 0); rb_define_method(cls, "rb_thread_local_aref", thread_spec_rb_thread_local_aref, 2); diff --git a/spec/ruby/optional/capi/thread_spec.rb b/spec/ruby/optional/capi/thread_spec.rb index df454d1ea8..35b58996b8 100644 --- a/spec/ruby/optional/capi/thread_spec.rb +++ b/spec/ruby/optional/capi/thread_spec.rb @@ -121,6 +121,10 @@ describe "C-API Thread function" do thr.value.should be_true end + it "runs a native function with the global lock unlocked" do + @t.rb_thread_call_without_gvl_native_function.should == Process.pid + end + guard -> { platform_is :mingw and ruby_version_is ""..."2.7" } do it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do thr = Thread.new do |