diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-25 22:06:44 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-25 22:07:09 +0900 |
commit | 25a332f5cf295e4b72814c39d87b4b3e2967dd68 (patch) | |
tree | ed52243d3e67feaaf27832b788d8ea66f6ebe301 /spec/ruby/optional/capi | |
parent | e880d075f847ff17e1bc77301a9ed363fb40525b (diff) | |
download | ruby-25a332f5cf295e4b72814c39d87b4b3e2967dd68.tar.gz |
Fix compilation on MSVC
* cast scalar value instead of function
* use `rb_pid_t` for the portability
Diffstat (limited to 'spec/ruby/optional/capi')
-rw-r--r-- | spec/ruby/optional/capi/ext/thread_spec.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/spec/ruby/optional/capi/ext/thread_spec.c b/spec/ruby/optional/capi/ext/thread_spec.c index 845c022fa1..11379bbf2f 100644 --- a/spec/ruby/optional/capi/ext/thread_spec.c +++ b/spec/ruby/optional/capi/ext/thread_spec.c @@ -73,20 +73,15 @@ static void* blocking_gvl_func_for_udf_io(void *data) { } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-function-type" -#endif +static void* ubf_pid(void *_) { + return (void *) (SIGNED_VALUE) getpid(); +} 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); + rb_pid_t ret = (rb_pid_t) (SIGNED_VALUE) rb_thread_call_without_gvl(ubf_pid, 0, RUBY_UBF_IO, 0); return LONG2FIX(ret); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* Returns true if the thread is interrupted. */ static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) { int fds[2]; |