pipe-posix: new module
authorEric Blake <eblake@redhat.com>
Fri, 10 Dec 2010 22:18:38 +0000 (15:18 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 10 Dec 2010 22:42:08 +0000 (15:42 -0700)
* 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>
ChangeLog
MODULES.html.sh
doc/posix-functions/pipe.texi
lib/unistd.in.h
m4/unistd_h.m4
modules/pipe-posix [new file with mode: 0644]
modules/unistd

index b1ad470..29849ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-12-10  Eric Blake  <eblake@redhat.com>
+
+       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.
+
 2010-12-07  Bruno Haible  <bruno@clisp.org>
 
        unistr/u8-strcmp: Avoid collision with libc function on Solaris 11.
index 983953c..456497f 100755 (executable)
@@ -2649,6 +2649,7 @@ func_all_modules ()
   func_module full-write
   func_module binary-io
   func_module isapipe
+  func_module pipe-posix
   func_module pipe2
   func_module pipe2-safer
   func_end_table
index b8cc508..420e400 100644 (file)
@@ -4,15 +4,15 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/pipe.html}
 
-Gnulib module: ---
+Gnulib module: pipe-posix
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function is missing on some platforms:
-mingw.
 @end itemize
index 4834e37..571afa1 100644 (file)
 # 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.
index e2f7f2b..0690951 100644 (file)
@@ -38,7 +38,7 @@ AC_DEFUN([gl_UNISTD_H],
     ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
     fsync ftruncate getcwd getdomainname getdtablesize getgroups
     gethostname getlogin getlogin_r getpagesize getusershell setusershell
-    endusershell lchown link linkat lseek pipe2 pread pwrite readlink
+    endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink
     readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
     usleep])
 ])
@@ -78,6 +78,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_LINK=0;             AC_SUBST([GNULIB_LINK])
   GNULIB_LINKAT=0;           AC_SUBST([GNULIB_LINKAT])
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
+  GNULIB_PIPE=0;             AC_SUBST([GNULIB_PIPE])
   GNULIB_PIPE2=0;            AC_SUBST([GNULIB_PIPE2])
   GNULIB_PREAD=0;            AC_SUBST([GNULIB_PREAD])
   GNULIB_PWRITE=0;           AC_SUBST([GNULIB_PWRITE])
diff --git a/modules/pipe-posix b/modules/pipe-posix
new file mode 100644 (file)
index 0000000..9f753db
--- /dev/null
@@ -0,0 +1,22 @@
+Description:
+Creation of a pipe.
+
+Files:
+
+Depends-on:
+unistd
+
+configure.ac:
+AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+gl_UNISTD_MODULE_INDICATOR([pipe])
+
+Makefile.am:
+
+Include:
+<unistd.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake
index 344a189..e2475dd 100644 (file)
@@ -52,6 +52,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
              -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
              -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
+             -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \
              -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
              -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
              -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \