changeset 34225:c81cd54c6d65

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. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Fri, 08 Apr 2011 10:22:00 -0600
parents f678c225705a
children 80a20352cd90
files ChangeLog doc/posix-headers/fcntl.texi lib/fcntl.in.h
diffstat 3 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 08 10:44:53 2011 -0600
+++ b/ChangeLog	Fri Apr 08 10:22:00 2011 -0600
@@ -1,5 +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.
+
 	pipe-filter: drop O_NONBLOCK workarounds
 	* modules/pipe-filter-gi (Depends-on): Add fcntl-h.
 	* modules/pipe-filter-ii (Depends-on): Likewise.
--- a/doc/posix-headers/fcntl.texi	Fri Apr 08 10:44:53 2011 -0600
+++ b/doc/posix-headers/fcntl.texi	Fri Apr 08 10:22:00 2011 -0600
@@ -23,6 +23,11 @@
 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.
--- a/lib/fcntl.in.h	Fri Apr 08 10:44:53 2011 -0600
+++ b/lib/fcntl.in.h	Fri Apr 08 10:22:00 2011 -0600
@@ -256,6 +256,11 @@
 # 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