raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] Prefer to use rb_io_descriptor in my_fileno
@ 2023-06-09  8:58 Samuel Williams
  2023-06-09 10:16 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Williams @ 2023-06-09  8:58 UTC (permalink / raw)
  To: raindrops-public; +Cc: Samuel Williams

---
 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] 5+ messages in thread

* Re: [PATCH] Prefer to use rb_io_descriptor in my_fileno
  2023-06-09  8:58 Samuel Williams
@ 2023-06-09 10:16 ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2023-06-09 10:16 UTC (permalink / raw)
  To: Samuel Williams; +Cc: raindrops-public

Samuel Williams <samuel.williams@oriontransfer.co.nz> wrote:
> ---

Where's the commit message body?

At minimum, non-trivial commits must have an explanation of why
a change is necessary.  This is important to reviewers who don't
follow Ruby core development closely.


Even one sentence for the "why" is fine as long as it can be
meaningful to offline reviewers.  References to online sources are
fine (full URLs, not #NNN); but it needs to be accompanied by a
summary for offline users.  See `git log' for examples.

In the case of this patch; I would also like to know which Ruby
implementation(s) and version(s) it appears in; and evidence
backing up that it's a supported public API we can depend on
going forward.


On a side note, describing "what" you're doing file-by-file
is totally uninteresting when it's obvious from reading
the patch.  IOW, old ruby.git and GNU ChangeLog conventions
are a waste of time+effort for users with `git log -p'.


Please ensure HTML is off and keep raindrops-public Cc-ed in responses.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Prefer to use rb_io_descriptor in my_fileno
       [not found] <5679D720-AD66-4471-9061-625159E71514@oriontransfer.co.nz>
@ 2023-06-09 11:01 ` Samuel Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Samuel Williams @ 2023-06-09 11:01 UTC (permalink / raw)
  Cc: raindrops-public


Eric, it’s part of CRuby’s public headers since 3.1 was released.

Introduced in 4b8903421828cb9d4de139180563ae8d8f04e1ab

Hope that helps.

Warm regards,
Samuel

> On 9/06/2023, at 7:16 PM, Eric Wong <e@80x24.org> wrote:
> 
> In the case of this patch; I would also like to know which Ruby
> implementation(s) and version(s) it appears in; and evidence
> backing up that it's a supported public API we can depend on
> going forward.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Prefer to use rb_io_descriptor in my_fileno
@ 2023-06-10  7:30 Jean Boussier
  2023-06-11 21:39 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Boussier @ 2023-06-10  7:30 UTC (permalink / raw)
  To: samuel.williams; +Cc: raindrops-public

>  the "why"

I think the missing piece here is that this change is necessary for compatibility with the current ruby master:

https://bugs.ruby-lang.org/issues/19057#note-17

kgio seem to have the same code and fail in the same way.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Prefer to use rb_io_descriptor in my_fileno
  2023-06-10  7:30 [PATCH] Prefer to use rb_io_descriptor in my_fileno Jean Boussier
@ 2023-06-11 21:39 ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2023-06-11 21:39 UTC (permalink / raw)
  To: Jean Boussier; +Cc: samuel.williams, raindrops-public, kgio-public

Jean Boussier <jean.boussier@gmail.com> wrote:
> >  the "why"
> 
> I think the missing piece here is that this change is necessary for compatibility with the current ruby master:
> 
> https://bugs.ruby-lang.org/issues/19057#note-17

Thanks, that's an important note omitted from both original patches.

I've pushed out Samuel's patch as commit
b3212417cc3e7cc44aa9e1ffe89b0d62ef3fdab5 to raindrops.git
with your comment

> kgio seem to have the same code and fail in the same way.

+Cc kgio-public@yhbt.net

I'll take documented patches for kgio, otherwise I'll try to deal with it
before Ruby 3.3 (or when Debian stable ships Ruby 3.3 :P).


I've also posted some raindrops cleanups and modernizations
which should reduce stack frames and binary size for 3.1+
(untested since I don't have space/time for multiple Ruby
installs atm):
https://yhbt.net/raindrops-public/20230611213328.379546-1-bofh@yhbt.net/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-11 21:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10  7:30 [PATCH] Prefer to use rb_io_descriptor in my_fileno Jean Boussier
2023-06-11 21:39 ` Eric Wong
     [not found] <5679D720-AD66-4471-9061-625159E71514@oriontransfer.co.nz>
2023-06-09 11:01 ` Samuel Williams
  -- strict thread matches above, loose matches on Subject: below --
2023-06-09  8:58 Samuel Williams
2023-06-09 10:16 ` Eric Wong

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).