resource: Add crate for sys/resource.h
Add the basics of sys/resource.h so that work can begin on sys/wait.h
This commit is contained in:
committed by
Dan Robertson
parent
2f718d40d6
commit
c6f16547ff
Generated
+10
@@ -257,6 +257,7 @@ dependencies = [
|
||||
"grp 0.1.0",
|
||||
"mman 0.1.0",
|
||||
"platform 0.1.0",
|
||||
"resource 0.1.0",
|
||||
"semaphore 0.1.0",
|
||||
"stat 0.1.0",
|
||||
"stdio 0.1.0",
|
||||
@@ -277,6 +278,15 @@ dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "resource"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.5.0",
|
||||
"platform 0.1.0",
|
||||
"sys_time 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-ap-proc_macro"
|
||||
version = "40.0.0"
|
||||
|
||||
+2
-1
@@ -12,13 +12,14 @@ members = ["src/crt0"]
|
||||
|
||||
[dependencies]
|
||||
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins.git", default-features = false, features = ["mem"] }
|
||||
platform = { path = "src/platform" }
|
||||
ctype = { path = "src/ctype" }
|
||||
errno = { path = "src/errno" }
|
||||
fcntl = { path = "src/fcntl" }
|
||||
grp = { path = "src/grp" }
|
||||
semaphore = { path = "src/semaphore" }
|
||||
mman = { path = "src/mman" }
|
||||
platform = { path = "src/platform" }
|
||||
resource = { path = "src/resource" }
|
||||
stat = { path = "src/stat" }
|
||||
stdio = { path = "src/stdio" }
|
||||
stdlib = { path = "src/stdlib" }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "resource"
|
||||
version = "0.1.0"
|
||||
authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
sys_time = { path = "../sys_time" }
|
||||
@@ -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/resource.h");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
include_guard = "_SYS_RESOURCE_H"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,49 @@
|
||||
//! sys/resource.h implementation for Redox, following
|
||||
//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysresource.h.html
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate platform;
|
||||
extern crate sys_time;
|
||||
|
||||
use platform::types::*;
|
||||
use sys_time::timeval;
|
||||
|
||||
type rlim_t = u64;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct rlimit {
|
||||
pub rlim_cur: rlim_t,
|
||||
pub rlim_max: rlim_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct rusage {
|
||||
pub ru_utime: timeval,
|
||||
pub ru_stime: timeval,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getpriority(which: c_int, who: id_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getrlimit(resource: c_int, rlp: *mut rlimit) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn setpriority(which: c_int, who: id_t, nice: c_int) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn setrlimit(resource: c_int, rlp: *const rlimit) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
Reference in New Issue
Block a user