From: Eric Blake Date: Fri, 10 Dec 2010 22:18:38 +0000 (-0700) Subject: pipe-posix: new module X-Git-Tag: v0.1~3564 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=e2f1471b021a285916339a73bc12c6b44dbf9a76;p=gnulib.git 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 --- diff --git a/ChangeLog b/ChangeLog index b1ad4705b..29849ba0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-12-10 Eric Blake + + 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 unistr/u8-strcmp: Avoid collision with libc function on Solaris 11. diff --git a/MODULES.html.sh b/MODULES.html.sh index 983953c3f..456497fad 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -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 diff --git a/doc/posix-functions/pipe.texi b/doc/posix-functions/pipe.texi index b8cc508c9..420e400ac 100644 --- a/doc/posix-functions/pipe.texi +++ b/doc/posix-functions/pipe.texi @@ -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 diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 4834e3749..571afa1ba 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -82,10 +82,14 @@ # include #endif -/* mingw declares getcwd in , not in . */ -#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ +/* mingw declares getcwd in , not in . It also provides + _pipe in , but that requires _O_BINARY from . */ +#if ((@GNULIB_GETCWD@ || @GNULIB_PIPE@ || defined GNULIB_POSIXCHECK) \ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) # include +# if @GNULIB_PIPE@ +# include +# endif #endif /* AIX and OSF/1 5.1 declare getdomainname in , not in . */ @@ -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. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index e2f7f2bf4..069095185 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -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 index 000000000..9f753db85 --- /dev/null +++ b/modules/pipe-posix @@ -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: + + +License: +LGPLv2+ + +Maintainer: +Eric Blake diff --git a/modules/unistd b/modules/unistd index 344a18932..e2475dd10 100644 --- a/modules/unistd +++ b/modules/unistd @@ -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' \