diff --git a/ext/ffi_c/Call.c b/ext/ffi_c/Call.c index e70e5f8a4..ce0539dec 100644 --- a/ext/ffi_c/Call.c +++ b/ext/ffi_c/Call.c @@ -43,6 +43,9 @@ #endif #include #include +#if defined(HAVE_RUBY_THREAD_H) +#include +#endif #if defined(HAVE_NATIVETHREAD) && (defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)) && !defined(_WIN32) # include # include @@ -317,7 +320,7 @@ rbffi_SetupCallParams(int argc, VALUE* argv, int paramCount, Type** paramTypes, } } -static VALUE +static void * call_blocking_function(void* data) { rbffi_blocking_call_t* b = (rbffi_blocking_call_t *) data; @@ -325,7 +328,7 @@ call_blocking_function(void* data) ffi_call(&b->cif, FFI_FN(b->function), b->retval, b->ffiValues); b->frame->has_gvl = true; - return Qnil; + return NULL; } VALUE diff --git a/ext/ffi_c/Function.c b/ext/ffi_c/Function.c index d9ba5c165..7047116bb 100644 --- a/ext/ffi_c/Function.c +++ b/ext/ffi_c/Function.c @@ -47,6 +47,9 @@ # endif #endif #include +#if defined(HAVE_RUBY_THREAD_H) +#include +#endif #include #if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) @@ -554,7 +557,7 @@ struct async_wait { bool stop; }; -static VALUE async_cb_wait(void *); +static void * async_cb_wait(void *); static void async_cb_stop(void *); #if defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) @@ -643,7 +646,7 @@ async_cb_event(void* unused) #endif #ifdef _WIN32 -static VALUE +static void * async_cb_wait(void *data) { struct async_wait* w = (struct async_wait *) data; @@ -665,7 +668,7 @@ async_cb_wait(void *data) LeaveCriticalSection(&async_cb_lock); - return Qnil; + return NULL; } static void @@ -680,7 +683,7 @@ async_cb_stop(void *data) } #else -static VALUE +static void * async_cb_wait(void *data) { struct async_wait* w = (struct async_wait *) data; @@ -700,7 +703,7 @@ async_cb_wait(void *data) pthread_mutex_unlock(&async_cb_mutex); - return Qnil; + return NULL; } static void diff --git a/ext/ffi_c/extconf.rb b/ext/ffi_c/extconf.rb index 23f466939..45ab9770f 100644 --- a/ext/ffi_c/extconf.rb +++ b/ext/ffi_c/extconf.rb @@ -26,6 +26,7 @@ end have_header('shlwapi.h') + have_header('ruby/thread.h') # for compat with ruby < 2.0 have_func('rb_thread_blocking_region') have_func('rb_thread_call_with_gvl') have_func('rb_thread_call_without_gvl')