diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-12 10:05:48 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-12 10:05:48 +0000 |
commit | 683b89070ebd3053a9317230274c279e32862187 (patch) | |
tree | 36edf02dccffce28b78be8c098c0da6113f9bd47 /spec/rubyspec | |
parent | e87cc8ea0d359d5123a33af7a193b0837c94d026 (diff) | |
download | ruby-683b89070ebd3053a9317230274c279e32862187.tar.gz |
Support bulding the extension on Windows
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec')
-rw-r--r-- | spec/rubyspec/optional/capi/ext/io_spec.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/rubyspec/optional/capi/ext/io_spec.c b/spec/rubyspec/optional/capi/ext/io_spec.c index 982284deab..91d86f5827 100644 --- a/spec/rubyspec/optional/capi/ext/io_spec.c +++ b/spec/rubyspec/optional/capi/ext/io_spec.c @@ -2,7 +2,9 @@ #include "rubyspec.h" #include "ruby/io.h" #include <fcntl.h> +#if HAVE_UNISTD_H #include <unistd.h> +#endif #ifdef __cplusplus extern "C" { @@ -10,13 +12,16 @@ extern "C" { static int set_non_blocking(int fd) { int flags; -#if defined(O_NONBLOCK) +#if defined(O_NONBLOCK) && defined(F_GETFL) if (-1 == (flags = fcntl(fd, F_GETFL, 0))) flags = 0; return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -#else +#elif defined(FIOBIO) flags = 1; return ioctl(fd, FIOBIO, &flags); +#else + errno = ENOSYS; + return -1; #endif } @@ -139,7 +144,8 @@ VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) { char buf[RB_IO_WAIT_READABLE_BUF]; wait_bool ret; - set_non_blocking(fd); + if (set_non_blocking(fd) == -1) + rb_sys_fail(0); if(RTEST(read_p)) { rb_ivar_set(self, rb_intern("@write_data"), Qtrue); |