Skip to content
Snippets Groups Projects
Commit 7e19ce23 authored by Paul Sajna's avatar Paul Sajna
Browse files

nanosleep

parent 083aa0ed
No related branches found
No related tags found
1 merge request!49Add time and sys/time
......@@ -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
}
......
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,
}
......@@ -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]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment