diff options
| -rw-r--r-- | ext/io/console/console.c | 12 | ||||
| -rw-r--r-- | ext/io/console/extconf.rb | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 91e12d9ff7..e59f5bf878 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -1566,7 +1566,13 @@ rb_io_closed_p(VALUE io) } #endif -#ifdef HAVE_RB_EXT_RACTOR_SAFE +#if defined(RB_EXT_RACTOR_SAFE) && defined(HAVE_RB_RACTOR_LOCAL_STORAGE_VALUE_NEWKEY) +# define USE_RACTOR_STORAGE 1 +#else +# define USE_RACTOR_STORAGE 0 +#endif + +#if USE_RACTOR_STORAGE #include "ruby/ractor.h" static rb_ractor_local_key_t key_console_dev; @@ -1813,12 +1819,12 @@ io_getpass(int argc, VALUE *argv, VALUE io) void Init_console(void) { -#ifdef HAVE_RB_EXT_RACTOR_SAFE +#if USE_RACTOR_STORAGE RB_EXT_RACTOR_SAFE(true); #endif #undef rb_intern -#ifdef HAVE_RB_EXT_RACTOR_SAFE +#if USE_RACTOR_STORAGE key_console_dev = rb_ractor_local_storage_value_newkey(); #else id_console = rb_intern("console"); diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb index 0cd8eaea0f..6161b747b5 100644 --- a/ext/io/console/extconf.rb +++ b/ext/io/console/extconf.rb @@ -10,6 +10,7 @@ have_func("rb_io_descriptor") have_func("rb_io_get_write_io") have_func("rb_io_closed_p") have_func("rb_io_open_descriptor") +have_func("rb_ractor_local_storage_value_newkey") is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"] # `ok` can be `true`, `false`, or `nil`: |
