aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--io.c2
-rw-r--r--ruby.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/io.c b/io.c
index 716bc6d506..b7e3316e3f 100644
--- a/io.c
+++ b/io.c
@@ -4981,7 +4981,7 @@ rb_io_oflags_fmode(int oflags)
{
int fmode = 0;
- switch (oflags & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ switch (oflags & O_ACCMODE) {
case O_RDONLY:
fmode = FMODE_READABLE;
break;
diff --git a/ruby.c b/ruby.c
index 8267002866..9cb03ee702 100644
--- a/ruby.c
+++ b/ruby.c
@@ -43,6 +43,9 @@
#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
+#ifndef O_ACCMODE
+# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+#endif
#include "ruby/util.h"
@@ -1739,9 +1742,10 @@ load_file_internal(VALUE arg)
}
else {
int fd, mode = O_RDONLY;
-#if defined O_NONBLOCK
+#if defined O_NONBLOCK && !(O_NONBLOCK & O_ACCMODE)
+ /* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */
mode |= O_NONBLOCK;
-#elif defined O_NDELAY
+#elif defined O_NDELAY && !(O_NDELAY & O_ACCMODE)
mod |= O_NDELAY;
#endif
#if defined DOSISH || defined __CYGWIN__