Browse Source

wait: Add crate for sys/wait.h

Add the basics of sys/wait.h so that we get a bit closer to being able
to compile libc-test.
Dan Robertson 7 years ago
parent
commit
ca7f3a00e6
6 changed files with 82 additions and 0 deletions
  1. 10 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 11 0
      src/wait/Cargo.toml
  4. 11 0
      src/wait/build.rs
  5. 6 0
      src/wait/cbindgen.toml
  6. 43 0
      src/wait/src/lib.rs

+ 10 - 0
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"

+ 1 - 0
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]

+ 11 - 0
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" }

+ 11 - 0
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");
+}

+ 6 - 0
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

+ 43 - 0
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!();
+}