summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Williams <[email protected]>2024-11-21 10:40:52 +1300
committergit <[email protected]>2024-11-20 21:40:55 +0000
commitf6e6e6687069cbefa5ba777d98d1f90b566b4ada (patch)
treec6926bcaa272ce2dcdf762066a3f153c8791b568
parentb143fd5bd8527da3ddd176a3d6a362d0ab3bc6c7 (diff)
[ruby/zlib] Add support for safe offload of nogvl code.
(https://github.com/ruby/zlib/pull/89) https://github.com/ruby/zlib/commit/a535271862
-rw-r--r--ext/zlib/zlib.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 0931905b47..d63fe02d57 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
}