diff options
author | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
commit | a990de90fe41456a23e58bd087d2f107d321f3a1 (patch) | |
tree | 15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/cc/src/os_pipe | |
parent | 3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff) | |
download | fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip |
Deleted vendor folder
Diffstat (limited to 'vendor/cc/src/os_pipe')
-rw-r--r-- | vendor/cc/src/os_pipe/unix.rs | 121 | ||||
-rw-r--r-- | vendor/cc/src/os_pipe/windows.rs | 24 |
2 files changed, 0 insertions, 145 deletions
diff --git a/vendor/cc/src/os_pipe/unix.rs b/vendor/cc/src/os_pipe/unix.rs deleted file mode 100644 index ec4e547..0000000 --- a/vendor/cc/src/os_pipe/unix.rs +++ /dev/null @@ -1,121 +0,0 @@ -use std::{ - fs::File, - io, - os::{raw::c_int, unix::io::FromRawFd}, -}; - -pub(super) fn pipe() -> io::Result<(File, File)> { - let mut fds = [0; 2]; - - // The only known way right now to create atomically set the CLOEXEC flag is - // to use the `pipe2` syscall. This was added to Linux in 2.6.27, glibc 2.9 - // and musl 0.9.3, and some other targets also have it. - #[cfg(any( - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox" - ))] - { - unsafe { - cvt(libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC))?; - } - } - - #[cfg(not(any( - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox" - )))] - { - unsafe { - cvt(libc::pipe(fds.as_mut_ptr()))?; - } - - cloexec::set_cloexec(fds[0])?; - cloexec::set_cloexec(fds[1])?; - } - - unsafe { Ok((File::from_raw_fd(fds[0]), File::from_raw_fd(fds[1]))) } -} - -fn cvt(t: c_int) -> io::Result<c_int> { - if t == -1 { - Err(io::Error::last_os_error()) - } else { - Ok(t) - } -} - -#[cfg(not(any( - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox" -)))] -mod cloexec { - use super::{c_int, cvt, io}; - - #[cfg(not(any( - target_env = "newlib", - target_os = "solaris", - target_os = "illumos", - target_os = "emscripten", - target_os = "fuchsia", - target_os = "l4re", - target_os = "linux", - target_os = "haiku", - target_os = "redox", - target_os = "vxworks", - target_os = "nto", - )))] - pub(super) fn set_cloexec(fd: c_int) -> io::Result<()> { - unsafe { - cvt(libc::ioctl(fd, libc::FIOCLEX))?; - } - - Ok(()) - } - - #[cfg(any( - all( - target_env = "newlib", - not(any(target_os = "espidf", target_os = "horizon")) - ), - target_os = "solaris", - target_os = "illumos", - target_os = "emscripten", - target_os = "fuchsia", - target_os = "l4re", - target_os = "linux", - target_os = "haiku", - target_os = "redox", - target_os = "vxworks", - target_os = "nto", - ))] - pub(super) fn set_cloexec(fd: c_int) -> io::Result<()> { - unsafe { - let previous = cvt(libc::fcntl(fd, libc::F_GETFD))?; - let new = previous | libc::FD_CLOEXEC; - if new != previous { - cvt(libc::fcntl(fd, libc::F_SETFD, new))?; - } - } - - Ok(()) - } - - // FD_CLOEXEC is not supported in ESP-IDF and Horizon OS but there's no need to, - // because neither supports spawning processes. - #[cfg(any(target_os = "espidf", target_os = "horizon"))] - pub(super) fn set_cloexec(_fd: c_int) -> io::Result<()> { - Ok(()) - } -} diff --git a/vendor/cc/src/os_pipe/windows.rs b/vendor/cc/src/os_pipe/windows.rs deleted file mode 100644 index 212632e..0000000 --- a/vendor/cc/src/os_pipe/windows.rs +++ /dev/null @@ -1,24 +0,0 @@ -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), - )) - } - } -} |