From 839c1e80ebeba7507f4bbfde152bde0d05de84bc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 2 Dec 2024 12:28:41 +0900 Subject: [PATCH] Check if `rb_syserr_fail_str` is available Truffle ruby seems to lack it. --- ext/io/console/console.c | 4 ++++ ext/io/console/extconf.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 4475953..4f71d6e 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -125,6 +125,10 @@ io_get_write_io_fallback(VALUE io) #define rb_io_get_write_io io_get_write_io_fallback #endif +#ifndef DHAVE_RB_SYSERR_FAIL_STR +# define rb_syserr_fail_str(e, mesg) rb_exc_raise(rb_syserr_new_str(e, mesg)) +#endif + #define sys_fail(io) do { \ int err = errno; \ rb_syserr_fail_str(err, rb_io_path(io)); \ diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb index 6161b74..30de410 100644 --- a/ext/io/console/extconf.rb +++ b/ext/io/console/extconf.rb @@ -5,6 +5,10 @@ # See https://bugs.ruby-lang.org/issues/20345 MakeMakefile::RbConfig ||= ::RbConfig +have_func("rb_syserr_fail_str(0, Qnil)") or +have_func("rb_syserr_new_str(0, Qnil)") or + abort + have_func("rb_io_path") have_func("rb_io_descriptor") have_func("rb_io_get_write_io")