* [PATCH] Improve compatibility with Ruby 3.3+
@ 2023-06-09 10:48 Samuel Williams
2023-06-09 10:53 ` Samuel Williams
0 siblings, 1 reply; 2+ messages in thread
From: Samuel Williams @ 2023-06-09 10:48 UTC (permalink / raw)
To: raindrops-public; +Cc: Samuel Williams
Prefer to use `rb_io_descriptor` in my_fileno if it is available. This
function was introduced in Ruby 3.1. Ruby 3.3 will deprecate access to
all internal fields of `rb_io_t`.
---
ext/raindrops/extconf.rb | 1 +
ext/raindrops/my_fileno.h | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 792e509..1733703 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -4,6 +4,7 @@
dir_config('atomic_ops')
have_func('mmap', 'sys/mman.h') or abort 'mmap() not found'
have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
+have_func('rb_io_descriptor')
$CPPFLAGS += " -D_GNU_SOURCE "
have_func('mremap', 'sys/mman.h')
diff --git a/ext/raindrops/my_fileno.h b/ext/raindrops/my_fileno.h
index 4c8ffba..00c5d29 100644
--- a/ext/raindrops/my_fileno.h
+++ b/ext/raindrops/my_fileno.h
@@ -3,6 +3,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;
if (TYPE(io) != T_FILE)
@@ -12,4 +18,5 @@ static int my_fileno(VALUE io)
if (fptr->fd < 0)
rb_raise(rb_eIOError, "closed stream");
return fptr->fd;
+#endif
}
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Improve compatibility with Ruby 3.3+
2023-06-09 10:48 [PATCH] Improve compatibility with Ruby 3.3+ Samuel Williams
@ 2023-06-09 10:53 ` Samuel Williams
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Williams @ 2023-06-09 10:53 UTC (permalink / raw)
To: raindrops-public
Eric, you will probably want to apply the same patch to kgio, including both using `rb_io_descriptor(io)` if it’s available, and also I recommend making the same changes to drop support for older Ruby versions as in d843802120e7cb01659b93917c29e3ba014216f1.
FYI, we will be at least deprecating all of the internals of rb_io_t in 3.3, and possibly removing it, if the breakage is minimal.
Kind regards,
Samuel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-09 10:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 10:48 [PATCH] Improve compatibility with Ruby 3.3+ Samuel Williams
2023-06-09 10:53 ` Samuel Williams
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.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).