fcntl-h: fix O_ACCMODE on cygwin
authorEric Blake <eblake@redhat.com>
Wed, 13 Apr 2011 21:07:25 +0000 (22:07 +0100)
committerIan Beckwith <ianb@erislabs.net>
Wed, 13 Apr 2011 21:07:25 +0000 (22:07 +0100)
* doc/posix-headers/fcntl.texi (fcntl.h): Document the bug.
* lib/fcntl.in.h (O_ACCMODE): Fix it.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit b277764ab1e0a68b1db0bf254ea4dbe8e16c0603)

ChangeLog
doc/posix-headers/fcntl.texi
lib/fcntl.in.h

index 902cada..be8e40e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-08  Eric Blake  <eblake@redhat.com>
+
+       fcntl-h: fix O_ACCMODE on cygwin
+       * doc/posix-headers/fcntl.texi (fcntl.h): Document the bug.
+       * lib/fcntl.in.h (O_ACCMODE): Fix it.
+
 2011-04-06  Eric Blake  <eblake@redhat.com>
 
        binary-io: relicense under LGPLv2+
index 1b64195..12f0f65 100644 (file)
@@ -18,6 +18,11 @@ these macros to 0.
 Gnulib defines these macros to @samp{O_RDONLY}, which is typically 0.
 
 @item
+The @samp{O_ACCMODE} mask mistakenly omits @samp{O_SEARCH} and
+@samp{O_EXEC} on some platforms:
+Cygwin.
+
+@item
 @samp{O_BINARY}, @samp{O_TEXT} (not specified by POSIX, but essential for
 portability to Woe32 platforms) are defined on some platforms but not on
 others.
index 18cac45..a238a85 100644 (file)
@@ -247,6 +247,11 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_TTY_INIT 0
 #endif
 
+#if O_ACCMODE != (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+# undef O_ACCMODE
+# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+#endif
+
 /* For systems that distinguish between text and binary I/O.
    O_BINARY is usually declared in fcntl.h  */
 #if !defined O_BINARY && defined _O_BINARY