diff --git a/Cargo.lock b/Cargo.lock index 316b19b9aa5f5ecbee1d2fd42a847b1735f5a7c2..919f68bce53b46fb6f3a52a3a6d375dacd2fa81c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index fd952f39026c59ca1fa7ca098a1400349bce7439..52bd487e6e8ce2a7d7941a65a4363eabf413c928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/src/resource/Cargo.toml b/src/resource/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..30cee970179f25980586034475e363b9f7c296d7 --- /dev/null +++ b/src/resource/Cargo.toml @@ -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" } diff --git a/src/resource/build.rs b/src/resource/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..a8c03a627ed6139aafd260a51a5e0ee664f9ab09 --- /dev/null +++ b/src/resource/build.rs @@ -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"); +} diff --git a/src/resource/cbindgen.toml b/src/resource/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..f9c595b682de5be84f518a4cb8fcd2c1e2a098bc --- /dev/null +++ b/src/resource/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = ["sys/types.h"] +include_guard = "_SYS_RESOURCE_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/resource/src/lib.rs b/src/resource/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..26b1d702a8b7807ded8185bcceada567255e5abf --- /dev/null +++ b/src/resource/src/lib.rs @@ -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!(); +}