Kaynağa Gözat

Add very basic example

Jeremy Soller 7 yıl önce
işleme
3267409c57
7 değiştirilmiş dosya ile 83 ekleme ve 0 silme
  1. 3 0
      .gitmodules
  2. 1 0
      openlibm
  3. 2 0
      unistd/.gitignore
  4. 14 0
      unistd/Cargo.toml
  5. 11 0
      unistd/build.rs
  6. 5 0
      unistd/cbindgen.toml
  7. 47 0
      unistd/src/lib.rs

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "openlibm"]
+	path = openlibm
+	url = https://github.com/redox-os/openlibm.git

+ 1 - 0
openlibm

@@ -0,0 +1 @@
+Subproject commit b7b3b4bc31aa4ae42b2562e6adb151e92aa3a82a

+ 2 - 0
unistd/.gitignore

@@ -0,0 +1,2 @@
+/Cargo.lock
+/target/

+ 14 - 0
unistd/Cargo.toml

@@ -0,0 +1,14 @@
+[package]
+name = "unistd"
+version = "0.1.0"
+authors = ["Jeremy Soller <[email protected]>"]
+
+[lib]
+name = "unistd"
+crate-type = ["cdylib"]
+
+[build-dependencies]
+cbindgen = "0.5"
+
+[dependencies]
+libc = "0.2"

+ 11 - 0
unistd/build.rs

@@ -0,0 +1,11 @@
+extern crate cbindgen;
+
+use std::env;
+
+fn main() {
+    let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+
+    cbindgen::generate(crate_dir)
+      .expect("Unable to generate bindings")
+      .write_to_file("target/unistd.h");
+}

+ 5 - 0
unistd/cbindgen.toml

@@ -0,0 +1,5 @@
+include_guard = "_UNISTD_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 47 - 0
unistd/src/lib.rs

@@ -0,0 +1,47 @@
+/// unistd implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/unistd.h.html
+
+extern crate libc;
+
+use libc::*;
+
+/*
+#[no_mangle]
+pub extern "C" fn name(arg) -> c_int {
+    unimplemented!();
+}
+*/
+
+#[no_mangle]
+pub extern "C" fn access(pathname: *const c_char, mode: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn alarm(seconds: c_uint) -> c_uint {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn brk(addr: *mut c_void) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn chdir(path: *const c_char) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn chroot(path: *const c_char) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn chown(pathname: *const c_char, owner: uid_t, group: gid_t) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn close(fd: c_int) -> c_int {
+    unimplemented!();
+}