Skip to content

Commit

Permalink
msvc: define O_ACCMODE
Browse files Browse the repository at this point in the history
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
that O_RDWR == O_RDONLY | O_WRONLY.

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 <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
Philip Oakley authored and dscho committed Nov 15, 2018
1 parent 4b94d4c commit db5aa8b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compat/msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static __inline int strcasecmp (const char *s1, const char *s2)
#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"

Expand Down

0 comments on commit db5aa8b

Please sign in to comment.