mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (internal_read_func, internal_write_func): split from
internal_io_func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3a0a3f4ea2
commit
96b0b1cf82
2 changed files with 16 additions and 12 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri May 2 23:59:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (internal_read_func, internal_write_func): split from
|
||||||
|
internal_io_func.
|
||||||
|
|
||||||
Fri May 2 23:55:15 2008 Tanaka Akira <akr@fsij.org>
|
Fri May 2 23:55:15 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* variable.c (rb_define_hooked_variable): guard *var from GC to
|
* variable.c (rb_define_hooked_variable): guard *var from GC to
|
||||||
|
|
19
io.c
19
io.c
|
@ -512,19 +512,20 @@ struct io_internal_struct {
|
||||||
int fd;
|
int fd;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t capa;
|
size_t capa;
|
||||||
int is_read;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
internal_io_func(void *ptr)
|
internal_read_func(void *ptr)
|
||||||
{
|
{
|
||||||
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
|
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
|
||||||
if (iis->is_read) {
|
|
||||||
return read(iis->fd, iis->buf, iis->capa);
|
return read(iis->fd, iis->buf, iis->capa);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
static VALUE
|
||||||
|
internal_write_func(void *ptr)
|
||||||
|
{
|
||||||
|
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
|
||||||
return write(iis->fd, iis->buf, iis->capa);
|
return write(iis->fd, iis->buf, iis->capa);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -534,9 +535,8 @@ rb_read_internal(int fd, void *buf, size_t count)
|
||||||
iis.fd = fd;
|
iis.fd = fd;
|
||||||
iis.buf = buf;
|
iis.buf = buf;
|
||||||
iis.capa = count;
|
iis.capa = count;
|
||||||
iis.is_read = 1;
|
|
||||||
|
|
||||||
return rb_thread_blocking_region(internal_io_func, &iis, RB_UBF_DFL, 0);
|
return rb_thread_blocking_region(internal_read_func, &iis, RB_UBF_DFL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -546,9 +546,8 @@ rb_write_internal(int fd, void *buf, size_t count)
|
||||||
iis.fd = fd;
|
iis.fd = fd;
|
||||||
iis.buf = buf;
|
iis.buf = buf;
|
||||||
iis.capa = count;
|
iis.capa = count;
|
||||||
iis.is_read = 0;
|
|
||||||
|
|
||||||
return rb_thread_blocking_region(internal_io_func, &iis, RB_UBF_DFL, 0);
|
return rb_thread_blocking_region(internal_write_func, &iis, RB_UBF_DFL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Reference in a new issue