From: Samuel Williams <samuel.williams@oriontransfer.co.nz>
To: kgio-public@yhbt.net
Cc: Jean Boussier <jean.boussier@gmail.com>
Subject: [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility
Date: Tue, 29 Aug 2023 11:46:40 +1200 [thread overview]
Message-ID: <20230828234640.74866-1-samuel.williams@oriontransfer.co.nz> (raw)
From: Jean Boussier <jean.boussier@gmail.com>
Ref: https://bugs.ruby-lang.org/issues/19057#note-17
Ruby 3.3 no longer fully expose rb_io_t which cause
kgio to think it's being compiled on an older Ruby.
The prefered API to use from Ruby 3.1 onwards is rb_io_descriptor.
---
ext/kgio/extconf.rb | 1 +
ext/kgio/my_fileno.h | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb
index 5b0b74a..54063f5 100644
--- a/ext/kgio/extconf.rb
+++ b/ext/kgio/extconf.rb
@@ -7,6 +7,7 @@ unless have_macro('CLOCK_MONOTONIC', 'time.h')
end
have_type('clockid_t', 'time.h')
have_library('rt', 'clock_gettime', 'time.h')
+have_func('rb_io_descriptor')
# taken from ext/socket/extconf.rb in ruby/trunk:
# OpenSolaris:
diff --git a/ext/kgio/my_fileno.h b/ext/kgio/my_fileno.h
index bdf1a5f..d9bda3c 100644
--- a/ext/kgio/my_fileno.h
+++ b/ext/kgio/my_fileno.h
@@ -22,6 +22,12 @@
static int my_fileno(VALUE io)
{
+#ifdef HAVE_RB_IO_DESCRIPTOR
+ if (TYPE(io) != T_FILE)
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
+
+ return rb_io_descriptor(io);
+#else
rb_io_t *fptr;
int fd;
@@ -33,4 +39,5 @@ static int my_fileno(VALUE io)
if (fd < 0)
rb_raise(rb_eIOError, "closed stream");
return fd;
+#endif
}
--
2.39.2 (Apple Git-143)
next reply other threads:[~2023-08-28 23:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 23:46 Samuel Williams [this message]
2023-09-05 9:22 ` [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/kgio/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230828234640.74866-1-samuel.williams@oriontransfer.co.nz \
--to=samuel.williams@oriontransfer.co.nz \
--cc=jean.boussier@gmail.com \
--cc=kgio-public@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kgio.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).