summaryrefslogtreecommitdiff
path: root/lib/unistd.in.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-12-10 15:18:38 -0700
committerEric Blake <eblake@redhat.com>2010-12-10 15:42:08 -0700
commite2f1471b021a285916339a73bc12c6b44dbf9a76 (patch)
treecb5e67bf0c23e2b9cb3b421cdf6414377807212a /lib/unistd.in.h
parent0de2016ec335422b91764e2c1430d37c5eb47874 (diff)
downloadgnulib-e2f1471b021a285916339a73bc12c6b44dbf9a76.tar.gz
pipe-posix: new module
* modules/pipe-posix: New file. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Set default. (gl_UNISTD_H): Check for declaration. * modules/unistd (Makefile.am): Substitute it. * lib/unistd.in.h (pipe): Provide it for mingw. * doc/posix-functions/pipe.texi (pipe): Update documentation. * MODULES.html.sh (File descriptor based Input/Output): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/unistd.in.h')
-rw-r--r--lib/unistd.in.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 4834e3749d..571afa1ba9 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -82,10 +82,14 @@
# include <stdlib.h>
#endif
-/* mingw declares getcwd in <io.h>, not in <unistd.h>. */
-#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
+/* mingw declares getcwd in <io.h>, not in <unistd.h>. It also provides
+ _pipe in <io.h>, but that requires _O_BINARY from <fcntl.h>. */
+#if ((@GNULIB_GETCWD@ || @GNULIB_PIPE@ || defined GNULIB_POSIXCHECK) \
&& ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
# include <io.h>
+# if @GNULIB_PIPE@
+# include <fcntl.h>
+# endif
#endif
/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. */
@@ -972,6 +976,22 @@ _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
#endif
+#if @GNULIB_PIPE@
+/* Create a pipe, defaulting to O_BINARY mode.
+ Store the read-end as fd[0] and the write-end as fd[1].
+ Return 0 upon success, or -1 with errno set upon failure. */
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define pipe(fd) _pipe (fd, 4096, _O_BINARY)
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef pipe
+# if HAVE_RAW_DECL_PIPE
+_GL_WARN_ON_USE (pipe, "pipe is unportable - "
+ "use gnulib module pipe for portability");
+# endif
+#endif
+
+
#if @GNULIB_PIPE2@
/* Create a pipe, applying the given flags when opening the read-end of the
pipe and the write-end of the pipe.