From 7ff405b36e2f6a6abebf99d6582f91f8c2a46adb Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 21 Nov 2024 10:20:01 +1300 Subject: [PATCH] Add support for safe offload of no-gvl code. --- ext/zlib/zlib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 0931905..d63fe02 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1042,6 +1042,11 @@ zstream_unblock_func(void *ptr) args->interrupt = 1; } +#ifndef RB_NOGVL_OFFLOAD_SAFE +// Default to no-op if it's not defined: +#define RB_NOGVL_OFFLOAD_SAFE 0 +#endif + static VALUE zstream_run_once_begin(VALUE _arguments) { @@ -1053,7 +1058,7 @@ zstream_run_once_begin(VALUE _arguments) #ifndef RB_NOGVL_UBF_ASYNC_SAFE return (VALUE)rb_thread_call_without_gvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments); #else - return (VALUE)rb_nogvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments, RB_NOGVL_UBF_ASYNC_SAFE); + return (VALUE)rb_nogvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments, RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_OFFLOAD_SAFE); #endif }