summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/io/wait/extconf.rb7
-rw-r--r--ext/io/wait/wait.c12
3 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e4d6831b9c..45b74c713a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/io/wait/extconf.rb, ext/io/wait/wait.c: Win32 platforms support.
+
Fri Jul 15 23:59:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (handle_class_module): handle a
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
index ea7dc9f6cf..1352ef202e 100644
--- a/ext/io/wait/extconf.rb
+++ b/ext/io/wait/extconf.rb
@@ -3,10 +3,15 @@ target = "io/wait"
unless macro_defined?("DOSISH", "#include <ruby.h>")
fionread = %w[sys/ioctl.h sys/filio.h].find do |h|
- checking_for("FIONREAD") {macro_defined?("FIONREAD", "#include <#{h}>\n")}
+ checking_for("FIONREAD") {have_macro("FIONREAD", h)}
end
if fionread
$defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
create_makefile(target)
end
+else
+ if have_func("rb_w32_ioctlsocket", "ruby.h")
+ have_func("rb_w32_is_socket", "ruby.h")
+ create_makefile(target)
+ end
end
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index 53d5bd7d18..41ba052850 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -15,7 +15,17 @@
#include "rubyio.h"
#include <sys/types.h>
+#if defined(FIONREAD_HEADER)
#include FIONREAD_HEADER
+#elif defined(HAVE_RB_W32_IOCTLSOCKET)
+#define ioctl ioctlsocket
+#endif
+
+#ifdef HAVE_RB_W32_IS_SOCKET
+#define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fptr->fd)
+#else
+#define FIONREAD_POSSIBLE_P(fd) Qtrue
+#endif
static VALUE io_ready_p _((VALUE io));
static VALUE io_wait _((int argc, VALUE *argv, VALUE io));
@@ -45,6 +55,7 @@ io_ready_p(io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
+ if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
fp = fptr->f;
if (feof(fp)) return Qfalse;
if (rb_read_pending(fp)) return Qtrue;
@@ -98,6 +109,7 @@ io_wait(argc, argv, io)
return Qnil;
}
+ if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
void
Init_wait()
{