summaryrefslogtreecommitdiff
path: root/lib/open.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-04-08 10:15:54 -0600
committerEric Blake <eblake@redhat.com>2011-04-08 10:58:36 -0600
commit70a72e0f50411ccc776379a761725d8c8bec58a3 (patch)
tree6d9fbc4447cddb8a6081cf4f34302eab06ff7a62 /lib/open.c
parent9cc991025d6139a3a8f3e0f1570bf39a66f3aafa (diff)
downloadgnulib-70a72e0f50411ccc776379a761725d8c8bec58a3.tar.gz
nonblocking: provide O_NONBLOCK for mingw
Mingw is the only known platform that lacks O_NONBLOCK (possibly via the alternate spelling O_NDELAY). But mingw also lacks any files where open() needs to enforce non-blocking behavior, and lacks openat(), so it is relatively simple to provide a non-zero flag. A future patches will make use of O_NONBLOCK for pipe2. * modules/nonblocking (Depends-on): Add open. (configure.ac): Set new witness macro. * m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Provide default for it. * modules/fcntl-h (Makefile.am): Substitute it. * lib/fcntl.in.h (O_NONBLOCK): Guarantee non-zero definition when nonblocking module is in use. * lib/nonblocking.c: Adjust portability test. * lib/open.c (open): Don't let native open see gnulib flag. * tests/test-fcntl-h.c (main): Enhance test. * tests/test-open.h (test_open): Likewise. * doc/posix-headers/fcntl.texi (fcntl.h): Document the replacement. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/open.c')
-rw-r--r--lib/open.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/open.c b/lib/open.c
index 2e2cc74dc6..e60b619949 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -63,6 +63,15 @@ open (const char *filename, int flags, ...)
va_end (arg);
}
+#if GNULIB_defined_O_NONBLOCK
+ /* The only known platform that lacks O_NONBLOCK is mingw, but it
+ also lacks named pipes and Unix sockets, which are the only two
+ file types that require non-blocking handling in open().
+ Therefore, it is safe to ignore O_NONBLOCK here. It is handy
+ that mingw also lacks openat(), so that is also covered here. */
+ flags &= ~O_NONBLOCK;
+#endif
+
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
if (strcmp (filename, "/dev/null") == 0)
filename = "NUL";