diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-08-31 17:34:21 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-08-31 08:43:59 +0000 |
| commit | e69945fc57efba5c8895c21235e109145865952d (patch) | |
| tree | ee58b30b98c4d83f300db23a1e3f3d7e7625f682 /ext | |
| parent | 4a1ea9b63ae24918e7aaddcb41de5dbe0f500d7f (diff) | |
[ruby/io-console] Workaround for old TruffleRuby
https://github.com/ruby/io-console/commit/f10c946ac7
Diffstat (limited to 'ext')
| -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`: |
