Both mingw-w64 implementations are just wrapper around CRT _pipe() function.
---
mingw-w64-crt/Makefile.am | 1 +
mingw-w64-crt/misc/pipe.c | 13 +++++++++++++
mingw-w64-crt/misc/pipe2.c | 13 +++++++++++++
mingw-w64-crt/testcases/t_assert.c | 3 ++-
mingw-w64-crt/testcases/t_safe_flush.c | 3 ++-
mingw-w64-crt/testcases/t_stderr_buffering.c | 3 ++-
mingw-w64-headers/crt/unistd.h | 3 +++
7 files changed, 36 insertions(+), 3 deletions(-)
create mode 100644 mingw-w64-crt/misc/pipe.c
create mode 100644 mingw-w64-crt/misc/pipe2.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 9c0d7d1f2d63..856353ddf27f 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1291,6 +1291,7 @@ src_libmingwex=\
misc/mingw_wcstold.c \
misc/mkstemp.c misc/mkdtemp.c \
misc/sleep.c \
+ misc/pipe.c misc/pipe2.c \
misc/strsafe.c \
misc/tdelete.c misc/tdestroy.c misc/tfind.c \
misc/tsearch.c misc/twalk.c \
diff --git a/mingw-w64-crt/misc/pipe.c b/mingw-w64-crt/misc/pipe.c
new file mode 100644
index 000000000000..535f831e55a0
--- /dev/null
+++ b/mingw-w64-crt/misc/pipe.c
@@ -0,0 +1,13 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <unistd.h>
+#include <io.h>
+
+int __cdecl pipe(int *pipefd)
+{
+ return _pipe(pipefd, 0 /* default buffer size */, 0 /* no flags */);
+}
diff --git a/mingw-w64-crt/misc/pipe2.c b/mingw-w64-crt/misc/pipe2.c
new file mode 100644
index 000000000000..d4575faf6b2d
--- /dev/null
+++ b/mingw-w64-crt/misc/pipe2.c
@@ -0,0 +1,13 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <unistd.h>
+#include <io.h>
+
+int __cdecl pipe2(int *pipefd, int flags)
+{
+ return _pipe(pipefd, 0 /* default buffer size */, flags);
+}
diff --git a/mingw-w64-crt/testcases/t_assert.c
b/mingw-w64-crt/testcases/t_assert.c
index 7e74ea70e83e..03eed4e76d39 100644
--- a/mingw-w64-crt/testcases/t_assert.c
+++ b/mingw-w64-crt/testcases/t_assert.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
/* mingw-w64 headers */
#include "libtest.h"
@@ -20,7 +21,7 @@ int main(int argc, char *argv[]) {
ssize_t size;
char buf[512];
- assert(_pipe(pipefd, 0, O_NOINHERIT) == 0);
+ assert(pipe2(pipefd, O_NOINHERIT) == 0);
/* set stderr fd to write side of pipe, will be used by _spawnl() */
assert((back_errfd = dup(STDERR_FILENO)) >= 0);
diff --git a/mingw-w64-crt/testcases/t_safe_flush.c
b/mingw-w64-crt/testcases/t_safe_flush.c
index 3e967f323725..2f46065c12d6 100644
--- a/mingw-w64-crt/testcases/t_safe_flush.c
+++ b/mingw-w64-crt/testcases/t_safe_flush.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -100,7 +101,7 @@ int parent_main(const char *argv0) {
size_t size = 0;
char buf[512];
- assert(_pipe(pipefd, 0, O_NOINHERIT) == 0);
+ assert(pipe2(pipefd, O_NOINHERIT) == 0);
/* set stdout fd to write side of pipe, will be used by _spawnl() */
assert((back_outfd = dup(STDOUT_FILENO)) >= 0);
diff --git a/mingw-w64-crt/testcases/t_stderr_buffering.c
b/mingw-w64-crt/testcases/t_stderr_buffering.c
index 35a885a714c4..f02863fe6f97 100644
--- a/mingw-w64-crt/testcases/t_stderr_buffering.c
+++ b/mingw-w64-crt/testcases/t_stderr_buffering.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -25,7 +26,7 @@ int main(int argc, char *argv[]) {
size_t size = 0;
char buf[512];
- assert(_pipe(pipefd, 0, _O_NOINHERIT) == 0);
+ assert(pipe2(pipefd, O_NOINHERIT) == 0);
/* set stderr fd to write side of pipe, will be used by _spawnl() */
assert((back_errfd = dup(STDERR_FILENO)) >= 0);
diff --git a/mingw-w64-headers/crt/unistd.h b/mingw-w64-headers/crt/unistd.h
index b9f1a7836e0d..a9c14a5c1382 100644
--- a/mingw-w64-headers/crt/unistd.h
+++ b/mingw-w64-headers/crt/unistd.h
@@ -82,6 +82,9 @@ int truncate64(const char *, _off64_t);
#endif
#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP || WINSTORECOMPAT */
+int __cdecl pipe(int *_Pipefd);
+int __cdecl pipe2(int *_Pipefd, int _Flags);
+
#ifdef __cplusplus
}
#endif
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public