summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-04 13:14:11 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-04 13:14:11 +0000
commit23444302d9200bcc41ce279a529f73cad63c3f05 (patch)
treecb541d972fd43a434593dca6c3aebcfcdd8fe560 /bignum.c
parent16cfd26a57c30e17bc3c116c83134420693ba5c4 (diff)
downloadruby-23444302d9200bcc41ce279a529f73cad63c3f05.tar.gz
introduce rb_nogvl C-API to mark ubf as async-signal-safe
zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index ee3b49fd04..5285e5979e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2572,6 +2572,7 @@ bigdivrem1(void *ptr)
return 0;
}
+/* async-signal-safe */
static void
rb_big_stop(void *ptr)
{
@@ -2636,7 +2637,7 @@ bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
if (bds.zn > 10000 || bds.yn > 10000) {
retry:
bds.stop = Qfalse;
- rb_thread_call_without_gvl(bigdivrem1, &bds, rb_big_stop, &bds);
+ rb_nogvl(bigdivrem1, &bds, rb_big_stop, &bds, RB_NOGVL_UBF_ASYNC_SAFE);
if (bds.stop == Qtrue) {
/* execute trap handler, but exception was not raised. */