summaryrefslogtreecommitdiff
path: root/vendor/cc/src/os_pipe/windows.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/cc/src/os_pipe/windows.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/cc/src/os_pipe/windows.rs')
-rw-r--r--vendor/cc/src/os_pipe/windows.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/cc/src/os_pipe/windows.rs b/vendor/cc/src/os_pipe/windows.rs
new file mode 100644
index 0000000..212632e
--- /dev/null
+++ b/vendor/cc/src/os_pipe/windows.rs
@@ -0,0 +1,24 @@
+use crate::windows_sys::{CreatePipe, INVALID_HANDLE_VALUE};
+use std::{fs::File, io, os::windows::prelude::*, ptr};
+
+/// NOTE: These pipes do not support IOCP.
+///
+/// If IOCP is needed, then you might want to emulate
+/// anonymous pipes with CreateNamedPipe, as Rust's stdlib does.
+pub(super) fn pipe() -> io::Result<(File, File)> {
+ let mut read_pipe = INVALID_HANDLE_VALUE;
+ let mut write_pipe = INVALID_HANDLE_VALUE;
+
+ let ret = unsafe { CreatePipe(&mut read_pipe, &mut write_pipe, ptr::null_mut(), 0) };
+
+ if ret == 0 {
+ Err(io::Error::last_os_error())
+ } else {
+ unsafe {
+ Ok((
+ File::from_raw_handle(read_pipe as RawHandle),
+ File::from_raw_handle(write_pipe as RawHandle),
+ ))
+ }
+ }
+}