From a7091b51a6c1e8c35a126711fdbebb5b5debf590 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 13 Apr 2011 22:07:25 +0100 Subject: [PATCH] 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 (cherry picked from commit b277764ab1e0a68b1db0bf254ea4dbe8e16c0603) --- ChangeLog | 6 ++++++ doc/posix-headers/fcntl.texi | 5 +++++ lib/fcntl.in.h | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 902cada43..be8e40e01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-08 Eric Blake + + 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 binary-io: relicense under LGPLv2+ diff --git a/doc/posix-headers/fcntl.texi b/doc/posix-headers/fcntl.texi index 1b6419518..12f0f65a3 100644 --- a/doc/posix-headers/fcntl.texi +++ b/doc/posix-headers/fcntl.texi @@ -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. diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 18cac454a..a238a8572 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -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 -- 2.11.0