Implement a proper mutex type for future usage
This commit is contained in:
@@ -166,6 +166,10 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(FTRUNCATE, fildes, length) }) as c_int
|
||||
}
|
||||
|
||||
fn futex(addr: *mut c_int, op: c_int, val: c_int) -> c_int {
|
||||
unsafe { syscall!(FUTEX, addr, op, val, 0, 0, 0) as c_int }
|
||||
}
|
||||
|
||||
fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
e(unsafe { syscall!(UTIMENSAT, fd, ptr::null::<c_char>(), times, 0) }) as c_int
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ pub trait Pal {
|
||||
|
||||
fn ftruncate(fildes: c_int, length: off_t) -> c_int;
|
||||
|
||||
fn futex(addr: *mut c_int, op: c_int, val: c_int) -> c_int;
|
||||
|
||||
fn futimens(fd: c_int, times: *const timespec) -> c_int;
|
||||
|
||||
fn utimens(path: &CStr, times: *const timespec) -> c_int;
|
||||
|
||||
@@ -340,6 +340,13 @@ impl Pal for Sys {
|
||||
e(syscall::ftruncate(fd as usize, len as usize)) as c_int
|
||||
}
|
||||
|
||||
fn futex(addr: *mut c_int, op: c_int, val: c_int) -> c_int {
|
||||
match unsafe { syscall::futex(addr as *mut i32, op as usize, val as i32, 0, ptr::null_mut()) } {
|
||||
Ok(success) => success as c_int,
|
||||
Err(err) => -(err.errno as c_int)
|
||||
}
|
||||
}
|
||||
|
||||
fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
let times = [unsafe { redox_timespec::from(&*times) }, unsafe {
|
||||
redox_timespec::from(&*times.offset(1))
|
||||
|
||||
Reference in New Issue
Block a user