ext/io/console/console.c in io-console-0.5.0 vs ext/io/console/console.c in io-console-0.5.2
- old
+ new
@@ -2,10 +2,11 @@
/*
* console IO module
*/
#include "ruby.h"
#include "ruby/io.h"
+#include "ruby/thread.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_FCNTL_H
@@ -184,13 +185,14 @@
if (r->vtime >= 0) t->c_cc[VTIME] = r->vtime;
#endif
#ifdef ISIG
if (r->intr) {
t->c_iflag |= BRKINT|IXON;
- t->c_lflag |= ISIG|IEXTEN;
+ t->c_lflag |= ISIG;
}
#endif
+ (void)r;
}
}
static void
set_cookedmode(conmode *t, void *arg)
@@ -452,30 +454,29 @@
getc_call(VALUE io)
{
return rb_funcallv(io, id_getc, 0, 0);
}
#else
-static VALUE
+static void *
nogvl_getch(void *p)
{
int len = 0;
wint_t *buf = p, c = _getwch();
switch (c) {
case WEOF:
break;
- return (VALUE)0;
case 0x00:
case 0xe0:
buf[len++] = c;
c = _getwch();
/* fall through */
default:
buf[len++] = c;
break;
}
- return (VALUE)len;
+ return (void *)(VALUE)len;
}
#endif
/*
* call-seq:
@@ -515,11 +516,14 @@
if (optp->intr) {
w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, to);
if (w < 0) rb_eof_error();
if (!(w & RB_WAITFD_IN)) return Qnil;
}
+ else {
+ rb_warning("vtime option ignored if intr flag is unset");
+ }
}
- len = (int)rb_thread_io_blocking_region(nogvl_getch, wbuf, fptr->fd);
+ len = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getch, wbuf, RUBY_UBF_IO, 0);
switch (len) {
case 0:
return Qnil;
case 2:
buf[0] = (char)wbuf[0];