Skip to content

Commit f10c946

Browse files
committed
Workaround for old TruffleRuby
1 parent 65e0ff8 commit f10c946

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ext/io/console/console.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,13 @@ rb_io_closed_p(VALUE io)
15661566
}
15671567
#endif
15681568

1569-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
1569+
#if defined(RB_EXT_RACTOR_SAFE) && defined(HAVE_RB_RACTOR_LOCAL_STORAGE_VALUE_NEWKEY)
1570+
# define USE_RACTOR_STORAGE 1
1571+
#else
1572+
# define USE_RACTOR_STORAGE 0
1573+
#endif
1574+
1575+
#if USE_RACTOR_STORAGE
15701576
#include "ruby/ractor.h"
15711577
static rb_ractor_local_key_t key_console_dev;
15721578

@@ -1813,12 +1819,12 @@ io_getpass(int argc, VALUE *argv, VALUE io)
18131819
void
18141820
Init_console(void)
18151821
{
1816-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
1822+
#if USE_RACTOR_STORAGE
18171823
RB_EXT_RACTOR_SAFE(true);
18181824
#endif
18191825

18201826
#undef rb_intern
1821-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
1827+
#if USE_RACTOR_STORAGE
18221828
key_console_dev = rb_ractor_local_storage_value_newkey();
18231829
#else
18241830
id_console = rb_intern("console");

ext/io/console/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
have_func("rb_io_get_write_io")
1111
have_func("rb_io_closed_p")
1212
have_func("rb_io_open_descriptor")
13+
have_func("rb_ractor_local_storage_value_newkey")
1314

1415
is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"]
1516
# `ok` can be `true`, `false`, or `nil`:

0 commit comments

Comments
 (0)