* lib/unistd.in.h: Don't include <io.h>, <fcntl.h> for pipe.
(pipe): Use common idiom, not a macro definition.
* lib/pipe.c: New file.
* m4/pipe.m4: New file.
* modules/pipe-posix (Description): Enhance.
(Files): Add lib/pipe.c, m4/pipe.m4.
(configure.ac): Invoke gl_FUNC_PIPE.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_PIPE.
* modules/unistd (Makefile.am): Substitute HAVE_PIPE.
* tests/test-unistd-c++.cc: Check the signature of pipe.
+2010-12-10 Bruno Haible <bruno@clisp.org>
+
+ pipe-posix: Make it work in C++ mode.
+ * lib/unistd.in.h: Don't include <io.h>, <fcntl.h> for pipe.
+ (pipe): Use common idiom, not a macro definition.
+ * lib/pipe.c: New file.
+ * m4/pipe.m4: New file.
+ * modules/pipe-posix (Description): Enhance.
+ (Files): Add lib/pipe.c, m4/pipe.m4.
+ (configure.ac): Invoke gl_FUNC_PIPE.
+ * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_PIPE.
+ * modules/unistd (Makefile.am): Substitute HAVE_PIPE.
+ * tests/test-unistd-c++.cc: Check the signature of pipe.
+
2010-12-10 Bruno Haible <bruno@clisp.org>
Rename module 'pipe' to 'spawn-pipe'.
--- /dev/null
+/* Create a pipe.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Woe32 API. */
+
+/* Get _pipe(). */
+# include <io.h>
+
+/* Get _O_BINARY. */
+# include <fcntl.h>
+
+int
+pipe (int fd[2])
+{
+ return _pipe (fd, 4096, _O_BINARY);
+}
+
+#else
+
+# error "This platform lacks a pipe function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
+
+#endif
# include <stdlib.h>
#endif
-/* 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) \
+/* mingw declares getcwd in <io.h>, not in <unistd.h>. */
+#if ((@GNULIB_GETCWD@ || 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>. */
/* 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)
+# if @HAVE_PIPE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define pipe rpl_pipe
+# endif
+_GL_FUNCDECL_RPL (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (pipe, int, (int fd[2]));
+# else
+_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
# endif
+_GL_CXXALIASWARN (pipe);
#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");
+ "use gnulib module pipe-posix for portability");
# endif
#endif
--- /dev/null
+# pipe.m4 serial 1
+dnl Copyright (C) 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_PIPE],
+[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
+ AC_CHECK_FUNCS_ONCE([pipe])
+ if test $ac_cv_func_pipe != yes; then
+ HAVE_PIPE=0
+ AC_LIBOBJ([pipe])
+ fi
+])
-# unistd_h.m4 serial 48
+# unistd_h.m4 serial 49
dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
HAVE_LINK=1; AC_SUBST([HAVE_LINK])
HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
+ HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
Description:
-Creation of a pipe.
+pipe() function: Creation of a pipe.
Files:
+lib/pipe.c
+m4/pipe.m4
Depends-on:
unistd
configure.ac:
-AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+gl_FUNC_PIPE
gl_UNISTD_MODULE_INDICATOR([pipe])
Makefile.am:
-e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
-e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
-e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+ -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
-e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
-e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
-e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
SIGNATURE_CHECK (GNULIB_NAMESPACE::lseek, off_t, (int, off_t, int));
#endif
+#if GNULIB_TEST_PIPE
+SIGNATURE_CHECK (GNULIB_NAMESPACE::pipe, int, (int[2]));
+#endif
+
#if GNULIB_TEST_PIPE2
SIGNATURE_CHECK (GNULIB_NAMESPACE::pipe2, int, (int[2], int));
#endif