nanosleep

This commit is contained in:
Paul Sajna
2018-03-09 03:26:45 -08:00
parent 083aa0ed55
commit 7e19ce23bd
4 changed files with 28 additions and 6 deletions
+4
View File
@@ -123,6 +123,10 @@ pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int {
e(unsafe { syscall!(MKDIRAT, AT_FDCWD, path, mode) }) as c_int
}
pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
e(unsafe { syscall!(NANOSLEEP, rqtp, rmtp) }) as c_int
}
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
e(unsafe { syscall!(OPENAT, AT_FDCWD, path, oflag, mode) }) as c_int
}
+10
View File
@@ -1,7 +1,9 @@
use core::ptr;
use core::slice;
use core::mem;
use syscall;
use syscall::flag::*;
use syscall::data::TimeSpec as redox_timespec;
use c_str;
use errno;
@@ -135,6 +137,14 @@ pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int {
}
}
pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
unsafe {
let rqtp = mem::transmute::<*const timespec, &redox_timespec>(rqtp);
let rmtp = mem::transmute::<*mut timespec, &mut redox_timespec>(rmtp);
e(syscall::nanosleep(rqtp, rmtp)) as c_int
}
}
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
let path = unsafe { c_str(path) };
e(syscall::open(path, (oflag as usize) | (mode as usize))) as c_int
+6
View File
@@ -63,3 +63,9 @@ pub type suseconds_t = i64;
pub type clock_t = i64;
pub type clockid_t = i32;
pub type timer_t = c_void;
#[repr(C)]
pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: c_long,
}