1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Support bulding the extension on Windows

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2017-05-12 10:05:48 +00:00
parent e87cc8ea0d
commit 683b89070e

View file

@ -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);