[08/17] msvc: define O_ACCMODE
diff mbox series

Message ID b23651a357db822aabb0b2e65dc962829a117645.1560860634.git.gitgitgadget@gmail.com
State New
Headers show
  • Fix MSVC support, at long last
Related show

Commit Message

Derrick Stolee via GitGitGadget June 18, 2019, 12:24 p.m. UTC
From: Philip Oakley <philipoakley@iee.org>

This constant is not defined in MSVC's headers.

In UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1
and 2, respectively. Yes, that means that UCRT breaks with the tradition

It is a perfectly legal way to define those constants, though, therefore
we need to take care of defining O_ACCMODE accordingly.

This is particularly important in order to keep our "open() can set
errno to EISDIR" emulation working: it tests that (flags & O_ACCMODE) is
not identical to O_RDONLY before going on to test specifically whether
the file for which open() reported EACCES is, in fact, a directory.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
 compat/msvc.h | 2 ++
 1 file changed, 2 insertions(+)

diff mbox series

diff --git a/compat/msvc.h b/compat/msvc.h
index 04b4750b87..d336d80670 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -19,6 +19,8 @@ 
 #undef ERROR
 typedef int sigset_t;
+/* open for reading, writing, or both (not in fcntl.h) */
+#define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)
 #include "compat/mingw.h"