summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-18 03:24:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-18 03:24:04 +0000
commit6b4ee352fb9d460e9b6080192657573810ca4d0e (patch)
tree4cab5b4f9b27907b8354bea66b8bbcdb4bc78f06
parent861c5e26d388e89dc60937129d3c3395f6d74162 (diff)
* ext/io/wait/wait.c: wrong backport from trunk. fixed: [ruby-dev:26562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--ext/io/wait/wait.c24
2 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index fce057545f..68b853392f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,14 @@
+Mon Jul 18 12:23:27 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * ext/io/wait/wait.c: wrong backport from trunk. fixed: [ruby-dev:26562]
+
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.
- * io.c (wsplit_p): new function.
- (io_fwrite): split writing data by PIPE_BUF if wsplit_p is true in
- multi-threaded mode.
+ * io.c (wsplit_p): new function.
+ (io_fwrite): split writing data by PIPE_BUF if wsplit_p is true in
+ multi-threaded mode.
Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index 75cfafe46e..61d6527b36 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -17,14 +17,21 @@
#include <sys/types.h>
#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));
@@ -51,16 +58,16 @@ io_ready_p(io)
{
OpenFile *fptr;
FILE *fp;
- int n;
+ ioctl_arg n;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
+ if (!FIONREAD_POSSIBLE_P(fileno(fptr->f))) return Qfalse;
fp = fptr->f;
if (feof(fp)) return Qfalse;
if (rb_read_pending(fp)) return Qtrue;
if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
- if (n > 0) return INT2NUM(n);
+ if (n > 0) return ioctl_arg2num(n);
return Qnil;
}
@@ -80,7 +87,8 @@ io_wait(argc, argv, io)
OpenFile *fptr;
fd_set rd;
FILE *fp;
- int fd, n;
+ int fd;
+ ioctl_arg n;
VALUE timeout;
struct timeval *tp, timerec;
@@ -104,7 +112,7 @@ io_wait(argc, argv, io)
if (rb_thread_select(fd + 1, &rd, NULL, NULL, tp) < 0)
rb_sys_fail(0);
rb_io_check_closed(fptr);
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
+ if (!FIONREAD_POSSIBLE_P(fileno(fptr->f))) return Qfalse;
if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
if (n > 0) return io;
return Qnil;