diff --git a/Cargo.lock b/Cargo.lock index 919f68bce53b46fb6f3a52a3a6d375dacd2fa81c..1aa856883c5c43b4d49b9df5d80398529d9ed954 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,6 +266,7 @@ dependencies = [ "sys_time 0.1.0", "time 0.1.0", "unistd 0.1.0", + "wait 0.1.0", "wctype 0.1.0", ] @@ -622,6 +623,15 @@ name = "vec_map" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wait" +version = "0.1.0" +dependencies = [ + "cbindgen 0.5.0", + "platform 0.1.0", + "resource 0.1.0", +] + [[package]] name = "wctype" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 52bd487e6e8ce2a7d7941a65a4363eabf413c928..8cbf11754be53cf7418a47dcbabdfc2bedb71c8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ string = { path = "src/string" } sys_time = { path = "src/sys_time" } time = { path = "src/time" } unistd = { path = "src/unistd" } +wait = { path = "src/wait" } wctype = { path = "src/wctype" } [profile.dev] diff --git a/src/wait/Cargo.toml b/src/wait/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..50d48a5efe7d627819fd979779d27326cfc535e9 --- /dev/null +++ b/src/wait/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "wait" +version = "0.1.0" +authors = ["Dan Robertson <danlrobertson89@gmail.com>"] + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../platform" } +resource = { path = "../resource" } diff --git a/src/wait/build.rs b/src/wait/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..53a786af45a1777d808df37b585f122fa42701fb --- /dev/null +++ b/src/wait/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/wait.h"); +} diff --git a/src/wait/cbindgen.toml b/src/wait/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..186d5f9573063eb9d2b1e625681131b372d77d41 --- /dev/null +++ b/src/wait/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = ["sys/types.h", "sys/resource.h"] +include_guard = "_SYS_WAIT_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/wait/src/lib.rs b/src/wait/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..51fdd28569e516767de612a1201b98fd5132eb90 --- /dev/null +++ b/src/wait/src/lib.rs @@ -0,0 +1,43 @@ +//! sys/wait.h implementation for Redox, following +//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/syswait.h.html + +#![no_std] + +extern crate platform; +extern crate resource; + +use platform::types::*; +use resource::rusage; + +#[no_mangle] +pub unsafe extern "C" fn wait(stat_loc: *mut c_int) -> pid_t { + unimplemented!(); +} + +#[no_mangle] +pub unsafe extern "C" fn wait3( + stat_loc: *mut c_int, + options: c_int, + resource_usage: *mut rusage, +) -> pid_t { + unimplemented!(); +} + +/* + * TODO: implement idtype_t, id_t, and siginfo_t + * + * #[no_mangle] + * pub unsafe extern "C" fn waitid( + * idtype: idtype_t, + * id: id_t, + * infop: siginfo_t, + * options: c_int + * ) -> c_int { + * unimplemented!(); + * } + */ + +#[no_mangle] +pub unsafe extern "C" fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t { + unimplemented!(); +}