mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/io/wait/wait.c: wrong backport from trunk, and compile error on
platforms fd_set is not a bit set. fixed: [ruby-dev:26562] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c2e1ce91c
commit
5e69b52014
2 changed files with 24 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Jul 18 12:23:27 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
|
* ext/io/wait/wait.c: wrong backport from trunk, and compile error on
|
||||||
|
platforms fd_set is not a bit set. fixed: [ruby-dev:26562]
|
||||||
|
|
||||||
Mon Jul 18 09:36:25 2005 Tanaka Akira <akr@m17n.org>
|
Mon Jul 18 09:36:25 2005 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* rubyio.h (FMODE_WSPLIT, FMODE_WSPLIT_INITIALIZED): new constant.
|
* rubyio.h (FMODE_WSPLIT, FMODE_WSPLIT_INITIALIZED): new constant.
|
||||||
|
@ -9,8 +14,8 @@ Mon Jul 18 09:36:25 2005 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
Mon Jul 18 05:00:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Jul 18 05:00:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/nkf/nkf-utf8/nkf.c: import nkf.c 1.73
|
* ext/nkf/nkf-utf8/nkf.c: import nkf.c 1.73
|
||||||
fix: TestKconv 1F
|
fix: TestKconv 1F
|
||||||
|
|
||||||
Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,21 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if defined(FIONREAD_HEADER)
|
#if defined(FIONREAD_HEADER)
|
||||||
#include FIONREAD_HEADER
|
#include FIONREAD_HEADER
|
||||||
#elif defined(HAVE_RB_W32_IOCTLSOCKET)
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_RB_W32_IOCTLSOCKET
|
||||||
#define ioctl ioctlsocket
|
#define ioctl ioctlsocket
|
||||||
|
#define ioctl_arg u_long
|
||||||
|
#define ioctl_arg2num(i) ULONG2NUM(i)
|
||||||
|
#else
|
||||||
|
#define ioctl_arg int
|
||||||
|
#define ioctl_arg2num(i) INT2NUM(i)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_RB_W32_IS_SOCKET
|
#ifdef HAVE_RB_W32_IS_SOCKET
|
||||||
#define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fptr->fd)
|
#define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fd)
|
||||||
#else
|
#else
|
||||||
#define FIONREAD_POSSIBLE_P(fd) Qtrue
|
#define FIONREAD_POSSIBLE_P(fd) ((fd),Qtrue)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static VALUE io_ready_p _((VALUE io));
|
static VALUE io_ready_p _((VALUE io));
|
||||||
|
@ -50,14 +57,14 @@ io_ready_p(io)
|
||||||
VALUE io;
|
VALUE io;
|
||||||
{
|
{
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
int n;
|
ioctl_arg n;
|
||||||
|
|
||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
rb_io_check_readable(fptr);
|
rb_io_check_readable(fptr);
|
||||||
if (rb_io_read_pending(fptr)) return Qtrue;
|
if (rb_io_read_pending(fptr)) return Qtrue;
|
||||||
if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
|
if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
|
||||||
if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
|
if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
|
||||||
if (n > 0) return INT2NUM(n);
|
if (n > 0) return ioctl_arg2num(n);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +100,8 @@ io_wait(argc, argv, io)
|
||||||
{
|
{
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
struct wait_readable_arg arg;
|
struct wait_readable_arg arg;
|
||||||
int fd, n;
|
int fd, i;
|
||||||
|
ioctl_arg n;
|
||||||
VALUE timeout;
|
VALUE timeout;
|
||||||
struct timeval timerec;
|
struct timeval timerec;
|
||||||
|
|
||||||
|
@ -114,12 +122,12 @@ io_wait(argc, argv, io)
|
||||||
rb_fd_init(&arg.fds);
|
rb_fd_init(&arg.fds);
|
||||||
rb_fd_set(fd, &arg.fds);
|
rb_fd_set(fd, &arg.fds);
|
||||||
#ifdef HAVE_RB_FD_INIT
|
#ifdef HAVE_RB_FD_INIT
|
||||||
n = (int)rb_ensure(wait_readable, (VALUE)&arg,
|
i = (int)rb_ensure(wait_readable, (VALUE)&arg,
|
||||||
(VALUE (*)_((VALUE)))rb_fd_term, (VALUE)&arg.fds);
|
(VALUE (*)_((VALUE)))rb_fd_term, (VALUE)&arg.fds);
|
||||||
#else
|
#else
|
||||||
n = rb_thread_select(fd + 1, rb_fd_ptr(&rd), NULL, NULL, tp)
|
i = rb_thread_select(fd + 1, rb_fd_ptr(&arg.fds), NULL, NULL, arg.timeout);
|
||||||
#endif
|
#endif
|
||||||
if (n < 0)
|
if (i < 0)
|
||||||
rb_sys_fail(0);
|
rb_sys_fail(0);
|
||||||
rb_io_check_closed(fptr);
|
rb_io_check_closed(fptr);
|
||||||
if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
|
if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue