From: "H.Yamamoto" Date: 2005-07-18T20:25:19+09:00 Subject: [ruby-dev:26569] Re: cannot compile io.c on windows 山本です。 >>よくは知らないのですが、windows にも nonblocking I/O は存在すると聞い >>たことがある気がするので、単に削るのは不適切なように感じます。 もしくは、わからないときは分割しないほうが良い、ということでしょうか。 Index: io.c =================================================================== RCS file: /src/ruby/io.c,v retrieving revision 1.368 diff -u -w -b -p -r1.368 io.c --- io.c 18 Jul 2005 00:59:32 -0000 1.368 +++ io.c 18 Jul 2005 10:54:33 -0000 @@ -375,6 +375,7 @@ io_alloc(klass) static int wsplit_p(OpenFile *fptr) { +#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK) int r; if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) { struct stat buf; @@ -387,6 +388,7 @@ wsplit_p(OpenFile *fptr) } fptr->mode |= FMODE_WSPLIT_INITIALIZED; } +#endif return fptr->mode & FMODE_WSPLIT; } または Index: io.c =================================================================== RCS file: /src/ruby/io.c,v retrieving revision 1.368 diff -u -w -b -p -r1.368 io.c --- io.c 18 Jul 2005 00:59:32 -0000 1.368 +++ io.c 18 Jul 2005 10:58:47 -0000 @@ -372,6 +372,7 @@ io_alloc(klass) return (VALUE)io; } +#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK) static int wsplit_p(OpenFile *fptr) { @@ -389,6 +390,7 @@ wsplit_p(OpenFile *fptr) } return fptr->mode & FMODE_WSPLIT; } +#endif static int io_fflush(fptr) @@ -409,12 +411,14 @@ io_fflush(fptr) wbuf_off = fptr->wbuf_off; wbuf_len = fptr->wbuf_len; l = fptr->wbuf_len; +#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK) if (PIPE_BUF < l && !rb_thread_critical && !rb_thread_alone() && wsplit_p(fptr)) { l = PIPE_BUF; } +#endif TRAP_BEG; r = write(fptr->fd, fptr->wbuf+fptr->wbuf_off, l); TRAP_END; /* xxx: signal handler may modify wbuf */ @@ -563,12 +567,14 @@ io_fwrite(str, fptr) } retry: l = n; +#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK) if (PIPE_BUF < l && !rb_thread_critical && !rb_thread_alone() && wsplit_p(fptr)) { l = PIPE_BUF; } +#endif TRAP_BEG; r = write(fptr->fd, RSTRING(str)->ptr+offset, l); TRAP_END; /* xxx: signal handler may modify given string. */ あと気になったのですが、F_SETFL + O_NONBLOCK でモードが変更された場合、 rb_io_ctl 辺りで FMODE_WSPLIT_INITIALIZED をクリアしないと追随できない ような気がします。(間違ってたらすみません) でも直接 fcntl(2) を呼ばれると追随できませんね・・・