* [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility
@ 2023-08-28 23:46 Samuel Williams
2023-09-05 9:22 ` Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Samuel Williams @ 2023-08-28 23:46 UTC (permalink / raw)
To: kgio-public; +Cc: Jean Boussier
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)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility
2023-08-28 23:46 [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility Samuel Williams
@ 2023-09-05 9:22 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2023-09-05 9:22 UTC (permalink / raw)
To: Samuel Williams; +Cc: kgio-public, Jean Boussier
Samuel Williams <samuel.williams@oriontransfer.co.nz> wrote:
> From: Jean Boussier <jean.boussier@gmail.com>
Thanks both, applied and pushed as
commit dbf5290cf9f89174f6b35a597af9a4226633d79b [1]
Will push out a release once docs are updated to more strongly
discourage the use of kgio and unicorn.
[1] https://yhbt.net/kgio.git/dbf5290cf9f89174f6b35a597af9a4226633d79b/s/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-05 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 23:46 [PATCH] Use rb_io_descriptor if available for Ruby 3.3 compatibility Samuel Williams
2023-09-05 9:22 ` Eric Wong
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).