Commit dd9328bd authored by Jeremy Soller's avatar Jeremy Soller

Add pipe2

parent 68c4e95b
......@@ -421,7 +421,12 @@ pub extern "C" fn pause() -> c_int {
#[no_mangle]
pub unsafe extern "C" fn pipe(fildes: *mut c_int) -> c_int {
Sys::pipe(slice::from_raw_parts_mut(fildes, 2))
pipe2(fildes, 0)
}
#[no_mangle]
pub unsafe extern "C" fn pipe2(fildes: *mut c_int, flags: c_int) -> c_int {
Sys::pipe2(slice::from_raw_parts_mut(fildes, 2), flags)
}
#[no_mangle]
......
......@@ -315,8 +315,8 @@ impl Pal for Sys {
e(unsafe { syscall!(OPENAT, AT_FDCWD, path.as_ptr(), oflag, mode) }) as c_int
}
fn pipe(fildes: &mut [c_int]) -> c_int {
e(unsafe { syscall!(PIPE2, fildes.as_mut_ptr(), 0) }) as c_int
fn pipe2(fildes: &mut [c_int], flags: c_int) -> c_int {
e(unsafe { syscall!(PIPE2, fildes.as_mut_ptr(), flags) }) as c_int
}
#[cfg(target_arch = "x86_64")]
......
......@@ -114,7 +114,7 @@ pub trait Pal {
fn open(path: &CStr, oflag: c_int, mode: mode_t) -> c_int;
fn pipe(fildes: &mut [c_int]) -> c_int;
fn pipe2(fildes: &mut [c_int], flags: c_int) -> c_int;
unsafe fn pte_clone(stack: *mut usize) -> pid_t;
......
......@@ -679,9 +679,9 @@ impl Pal for Sys {
)) as c_int
}
fn pipe(fds: &mut [c_int]) -> c_int {
fn pipe(fds: &mut [c_int], flags: c_int) -> c_int {
let mut usize_fds: [usize; 2] = [0; 2];
let res = e(syscall::pipe2(&mut usize_fds, 0));
let res = e(syscall::pipe2(&mut usize_fds, flags as usize));
fds[0] = usize_fds[0] as c_int;
fds[1] = usize_fds[1] as c_int;
res as c_int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment