nanosleep
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
+8
-6
@@ -6,11 +6,13 @@ extern crate platform;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
/*
|
||||
*#[repr(C)]
|
||||
*pub struct timespec {
|
||||
* pub tv_sec: time_t,
|
||||
* pub tv_nsec: c_long,
|
||||
*}
|
||||
*/
|
||||
|
||||
#[repr(C)]
|
||||
pub struct tm {
|
||||
@@ -112,7 +114,7 @@ pub extern "C" fn mktime(timeptr: *mut tm) -> time_t {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
|
||||
unimplemented!();
|
||||
platform::nanosleep(rqtp, rmtp)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user