diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-01-16 23:47:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-16 23:47:10 +0900 |
commit | 2dff82bfca0226e335a446715b94670b5af85108 (patch) | |
tree | 6aba6e30cf2a83ae2540c36fa8b27a71aba217d6 /ruby.c | |
parent | 4cd6fd338f71278bab5798a556a76c4e1588b892 (diff) |
`O_NONBLOCK` is not always a preprocessor constant on all platforms
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5454
Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -2323,14 +2323,15 @@ open_load_file(VALUE fname_v, int *xflag) int fd; /* open(2) may block if fname is point to FIFO and it's empty. Let's use O_NONBLOCK. */ -#if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE) + const int MODE_TO_LOAD = O_RDONLY | ( +#if defined O_NONBLOCK && HAVE_FCNTL /* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */ -# define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK) -#elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE) -# define MODE_TO_LOAD (O_RDONLY | O_NDELAY) -#else -# define MODE_TO_LOAD (O_RDONLY) + !(O_NONBLOCK & O_ACCMODE) ? O_NONBLOCK : +#endif +#if defined O_NDELAY && HAVE_FCNTL + !(O_NDELAY & O_ACCMODE) ? O_NDELAY : #endif + 0); int mode = MODE_TO_LOAD; #if defined DOSISH || defined __CYGWIN__ # define isdirsep(x) ((x) == '/' || (x) == '\\') |