Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- "3.0"
- "3.1"
- "3.2"
# - "head"
- "head"

experimental: [false]

Expand Down
1 change: 1 addition & 0 deletions ext/cool.io/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

$defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}"

have_func('rb_io_descriptor')
have_func('rb_thread_blocking_region')
have_func('rb_thread_call_without_gvl')
have_func('rb_thread_alone')
Expand Down
11 changes: 8 additions & 3 deletions ext/cool.io/iowatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include "ruby.h"
#if defined(HAVE_RUBY_IO_H)
#if defined(HAVE_RUBY_IO_H) || defined(HAVE_RB_IO_DESCRIPTOR)
#include "ruby/io.h"
#else
#include "rubyio.h"
Expand Down Expand Up @@ -65,7 +65,7 @@ static VALUE Coolio_IOWatcher_initialize(int argc, VALUE *argv, VALUE self)
char *flags_str;
int events;
struct Coolio_Watcher *watcher_data;
#if HAVE_RB_IO_T
#if defined(HAVE_RB_IO_T) || defined(HAVE_RB_IO_DESCRIPTOR)
rb_io_t *fptr;
#else
OpenFile *fptr;
Expand All @@ -88,10 +88,15 @@ static VALUE Coolio_IOWatcher_initialize(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "invalid event type: '%s' (must be 'r', 'w', or 'rw')", flags_str);

Data_Get_Struct(self, struct Coolio_Watcher, watcher_data);
GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
io = rb_convert_type(io, T_FILE, "IO", "to_io");
GetOpenFile(io, fptr);

watcher_data->dispatch_callback = Coolio_IOWatcher_dispatch_callback;
#ifdef HAVE_RB_IO_DESCRIPTOR
ev_io_init(&watcher_data->event_types.ev_io, Coolio_IOWatcher_libev_callback, rb_io_descriptor(io), events);
#else
ev_io_init(&watcher_data->event_types.ev_io, Coolio_IOWatcher_libev_callback, FPTR_TO_FD(fptr), events);
#endif
watcher_data->event_types.ev_io.data = (void *)self;

return Qnil;
Expand Down
1 change: 1 addition & 0 deletions ext/iobuffer/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'mkmf'

dir_config("iobuffer")
have_func("rb_io_descriptor")
have_library("c", "main")
if have_macro("HAVE_RB_IO_T", "ruby/io.h")
have_struct_member("rb_io_t", "fd", "ruby/io.h")
Expand Down
18 changes: 14 additions & 4 deletions ext/iobuffer/iobuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,22 @@ IO_Buffer_read_from(VALUE self, VALUE io)
{
struct buffer *buf;
int ret;
#if HAVE_RB_IO_T
#if defined(HAVE_RB_IO_T) || defined(HAVE_RB_IO_DESCRIPTOR)
rb_io_t *fptr;
#else
OpenFile *fptr;
#endif

Data_Get_Struct(self, struct buffer, buf);
GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
io = rb_convert_type(io, T_FILE, "IO", "to_io");
GetOpenFile(io, fptr);
rb_io_set_nonblock(fptr);

#ifdef HAVE_RB_IO_DESCRIPTOR
ret = rb_io_descriptor(io);
#else
ret = buffer_read_from(buf, FPTR_TO_FD(fptr));
#endif
return ret == -1 ? Qnil : INT2NUM(ret);
}

Expand All @@ -404,17 +409,22 @@ static VALUE
IO_Buffer_write_to(VALUE self, VALUE io)
{
struct buffer *buf;
#if HAVE_RB_IO_T
#if defined(HAVE_RB_IO_T) || defined(HAVE_RB_IO_DESCRIPTOR)
rb_io_t *fptr;
#else
OpenFile *fptr;
#endif

Data_Get_Struct(self, struct buffer, buf);
GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
io = rb_convert_type(io, T_FILE, "IO", "to_io");
GetOpenFile(io, fptr);
rb_io_set_nonblock(fptr);

#ifdef HAVE_RB_IO_DESCRIPTOR
return INT2NUM(rb_io_descriptor(io));
#else
return INT2NUM(buffer_write_to(buf, FPTR_TO_FD(fptr)));
#endif
}

/*
Expand Down