Implement sys/times.h on linux
This commit is contained in:
@@ -31,6 +31,7 @@ pub extern crate sys_resource;
|
||||
pub extern crate sys_socket;
|
||||
pub extern crate sys_stat;
|
||||
pub extern crate sys_time;
|
||||
pub extern crate sys_times;
|
||||
pub extern crate sys_un;
|
||||
pub extern crate sys_utsname;
|
||||
pub extern crate sys_wait;
|
||||
|
||||
@@ -392,6 +392,10 @@ pub fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *m
|
||||
e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int
|
||||
}
|
||||
|
||||
pub fn times(out: *mut tms) -> clock_t {
|
||||
unsafe { syscall!(TIMES, out) as clock_t }
|
||||
}
|
||||
|
||||
pub fn uname(utsname: *mut utsname) -> c_int {
|
||||
e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
|
||||
}
|
||||
|
||||
@@ -821,6 +821,15 @@ pub fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *m
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn times(out: *mut tms) -> clock_t {
|
||||
let _ = write!(
|
||||
::FileWriter(2),
|
||||
"unimplemented: times({:p})",
|
||||
out
|
||||
);
|
||||
!0
|
||||
}
|
||||
|
||||
pub fn unlink(path: *const c_char) -> c_int {
|
||||
let path = unsafe { c_str(path) };
|
||||
e(syscall::unlink(path)) as c_int
|
||||
|
||||
@@ -223,3 +223,11 @@ pub struct rusage {
|
||||
pub ru_nvcsw: c_long,
|
||||
pub ru_nivcsw: c_long
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct tms {
|
||||
tms_utime: clock_t,
|
||||
tms_stime: clock_t,
|
||||
tms_cutime: clock_t,
|
||||
tms_cstime: clock_t
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "sys_times"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
@@ -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/times.h");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
include_guard = "_SYS_TIMES_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,20 @@
|
||||
//! sys/times.h implementation
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate platform;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct tms {
|
||||
tms_utime: clock_t,
|
||||
tms_stime: clock_t,
|
||||
tms_cutime: clock_t,
|
||||
tms_cstime: clock_t
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn times(out: *mut tms) -> clock_t {
|
||||
platform::times(out as *mut platform::types::tms)
|
||||
}
|
||||
Reference in New Issue
Block a user