summaryrefslogtreecommitdiff
path: root/ext/-test-/wait/wait.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-06-29 21:58:31 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-06-29 23:54:41 +1200
commit5e75280c8edcd0f3c8f79d0c532cbfd18074886a (patch)
treeb7844bfa367298e87849e7eeb3423b7313faebdd /ext/-test-/wait/wait.c
parent39f99b8176ddec14058919ae8a317ea0c5216812 (diff)
Add basic test for updated IO wait functions.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4612
Diffstat (limited to 'ext/-test-/wait/wait.c')
-rw-r--r--ext/-test-/wait/wait.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/ext/-test-/wait/wait.c b/ext/-test-/wait/wait.c
new file mode 100644
index 0000000000..b73ee35809
--- /dev/null
+++ b/ext/-test-/wait/wait.c
@@ -0,0 +1,39 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+io_wait(VALUE klass, VALUE io, VALUE events, VALUE timeout)
+{
+ return rb_io_wait(io, events, timeout);
+}
+
+static VALUE
+io_maybe_wait(VALUE klass, VALUE error, VALUE io, VALUE events, VALUE timeout)
+{
+ return rb_io_maybe_wait(RB_NUM2INT(error), io, events, timeout);
+}
+
+static VALUE
+io_maybe_wait_readable(VALUE klass, VALUE error, VALUE io, VALUE timeout)
+{
+ return RB_INT2NUM(
+ rb_io_maybe_wait_readable(RB_NUM2INT(error), io, timeout)
+ );
+}
+
+static VALUE
+io_maybe_wait_writable(VALUE klass, VALUE error, VALUE io, VALUE timeout)
+{
+ return RB_INT2NUM(
+ rb_io_maybe_wait_writable(RB_NUM2INT(error), io, timeout)
+ );
+}
+
+void
+Init_wait(void)
+{
+ rb_define_singleton_method(rb_cIO, "io_wait", io_wait, 3);
+ rb_define_singleton_method(rb_cIO, "io_maybe_wait", io_maybe_wait, 4);
+ rb_define_singleton_method(rb_cIO, "io_maybe_wait_readable", io_maybe_wait_readable, 3);
+ rb_define_singleton_method(rb_cIO, "io_maybe_wait_writable", io_maybe_wait_writable, 3);
+}