add time and sys/time

This commit is contained in:
Paul Sajna
2018-03-09 02:46:14 -08:00
parent e676440e1f
commit 72909b3f4c
12 changed files with 327 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "sys_time"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../../cbindgen" }
[dependencies]
platform = { path = "../platform" }
+11
View File
@@ -0,0 +1,11 @@
extern crate cbindgen;
use std::{env, fs};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
fs::create_dir_all("../../target/include").expect("failed to create include directory");
cbindgen::generate(crate_dir)
.expect("failed to generate bindings")
.write_to_file("../../target/include/sys/time.h");
}
+6
View File
@@ -0,0 +1,6 @@
sys_includes = ["sys/types.h"]
include_guard = "_SYS_TIME_H"
language = "C"
[enum]
prefix_with_name = true
+61
View File
@@ -0,0 +1,61 @@
//! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
#![no_std]
extern crate platform;
use platform::types::*;
#[repr(C)]
pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
}
#[repr(C)]
pub struct itimerval {
pub it_interval: timeval,
pub it_value: timeval,
}
#[repr(C)]
pub struct fd_set {
pub fds_bits: [c_long; 16usize],
}
pub extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
unimplemented!();
}
pub extern "C" fn setitimer(
which: c_int,
value: *const itimerval,
ovalue: *mut itimerval,
) -> c_int {
unimplemented!();
}
pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *const c_void) -> c_int {
unimplemented!();
}
pub extern "C" fn select(
nfds: c_int,
readfds: *mut fd_set,
writefds: *mut fd_set,
errorfds: *mut fd_set,
timeout: *mut timeval,
) -> c_int {
unimplemented!();
}
pub extern "C" fn utimes(path: *const c_char, times: [timeval; 2]) -> c_int {
unimplemented!();
}
/*
#[no_mangle]
pub extern "C" fn func(args) -> c_int {
unimplemented!();
}
*/