浏览代码

Add template

Jeremy Soller 7 年之前
父节点
当前提交
a9f2e9a9a7
共有 6 个文件被更改,包括 50 次插入0 次删除
  1. 7 0
      include/bits/wchar.h
  2. 1 0
      platform/src/types.rs
  3. 11 0
      src/template/Cargo.toml
  4. 11 0
      src/template/build.rs
  5. 6 0
      src/template/cbindgen.toml
  6. 14 0
      src/template/src/lib.rs

+ 7 - 0
include/bits/wchar.h

@@ -0,0 +1,7 @@
+#ifndef _BITS_WCHAR_H
+#define _BITS_WCHAR_H
+
+typedef signed short wchar_t;
+typedef signed int wint_t;
+
+#endif /* _BITS_WCHAR_H */

+ 1 - 0
platform/src/types.rs

@@ -43,6 +43,7 @@ pub type c_long = i64;
 pub type c_ulong = u64;
 
 pub type wchar_t = i16;
+pub type wint_t = i32;
 
 pub type off_t = c_long;
 pub type mode_t = u16;

+ 11 - 0
src/template/Cargo.toml

@@ -0,0 +1,11 @@
+[package]
+name = "template"
+version = "0.1.0"
+authors = ["Jeremy Soller <jackpot51@gmail.com>"]
+build = "build.rs"
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+platform = { path = "../../platform" }

+ 11 - 0
src/template/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/template.h");
+}

+ 6 - 0
src/template/cbindgen.toml

@@ -0,0 +1,6 @@
+sys_includes = []
+include_guard = "_TEMPLATE_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 14 - 0
src/template/src/lib.rs

@@ -0,0 +1,14 @@
+//! template implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/template.h.html
+
+#![no_std]
+
+extern crate platform;
+
+use platform::types::*;
+
+/*
+#[no_mangle]
+pub extern "C" fn func(args) -> c_int {
+    unimplemented!();
+}
+*/