From 5e69b520145f7280ddd3bf6103124007683b9e63 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 18 Jul 2005 03:23:47 +0000 Subject: [PATCH] * 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 --- ChangeLog | 9 +++++++-- ext/io/wait/wait.c | 26 +++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 303f381408..d2698fcbff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jul 18 12:23:27 2005 Hirokazu Yamamoto + + * 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 * rubyio.h (FMODE_WSPLIT, FMODE_WSPLIT_INITIALIZED): new constant. @@ -9,8 +14,8 @@ Mon Jul 18 09:36:25 2005 Tanaka Akira Mon Jul 18 05:00:00 2005 NARUSE, Yui - * ext/nkf/nkf-utf8/nkf.c: import nkf.c 1.73 - fix: TestKconv 1F + * ext/nkf/nkf-utf8/nkf.c: import nkf.c 1.73 + fix: TestKconv 1F Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index 25494c0f28..1226007b63 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -17,14 +17,21 @@ #include #if defined(FIONREAD_HEADER) #include FIONREAD_HEADER -#elif defined(HAVE_RB_W32_IOCTLSOCKET) +#endif + +#ifdef HAVE_RB_W32_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 #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 -#define FIONREAD_POSSIBLE_P(fd) Qtrue +#define FIONREAD_POSSIBLE_P(fd) ((fd),Qtrue) #endif static VALUE io_ready_p _((VALUE io)); @@ -50,14 +57,14 @@ io_ready_p(io) VALUE io; { OpenFile *fptr; - int n; + ioctl_arg n; GetOpenFile(io, fptr); rb_io_check_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse; 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; } @@ -93,7 +100,8 @@ io_wait(argc, argv, io) { OpenFile *fptr; struct wait_readable_arg arg; - int fd, n; + int fd, i; + ioctl_arg n; VALUE timeout; struct timeval timerec; @@ -114,12 +122,12 @@ io_wait(argc, argv, io) rb_fd_init(&arg.fds); rb_fd_set(fd, &arg.fds); #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); #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 - if (n < 0) + if (i < 0) rb_sys_fail(0); rb_io_check_closed(fptr); if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);