Fix compilation on MSVC

* cast scalar value instead of function
* use `rb_pid_t` for the portability
This commit is contained in:
Nobuyoshi Nakada 2020-10-25 22:06:44 +09:00
parent e880d075f8
commit 25a332f5cf
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -73,19 +73,14 @@ static void* blocking_gvl_func_for_udf_io(void *data) {
} }
} }
#if defined(__GNUC__) || defined(__clang__) static void* ubf_pid(void *_) {
#pragma GCC diagnostic push return (void *) (SIGNED_VALUE) getpid();
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
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);
} }
#if defined(__GNUC__) || defined(__clang__) static VALUE thread_spec_rb_thread_call_without_gvl_native_function(VALUE self) {
#pragma GCC diagnostic pop rb_pid_t ret = (rb_pid_t) (SIGNED_VALUE) rb_thread_call_without_gvl(ubf_pid, 0, RUBY_UBF_IO, 0);
#endif return LONG2FIX(ret);
}
/* Returns true if the thread is interrupted. */ /* Returns true if the thread is interrupted. */
static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) { static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) {