[ruby/io-console] Workaround for old TruffleRuby

https://github.com/ruby/io-console/commit/f10c946ac7
This commit is contained in:
Nobuyoshi Nakada 2024-08-31 17:34:21 +09:00 committed by git
parent 4a1ea9b63a
commit e69945fc57
2 changed files with 10 additions and 3 deletions

View File

@ -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");

View File

@ -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`: