diff --git a/Cargo.lock b/Cargo.lock index a485ed6ca60ce35e7a0b02ce56a0743a5fe94b18..8be22825dbc92991555f0b59323663ead9181f8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,14 @@ dependencies = [ "platform 0.1.0", ] +[[package]] +name = "ctype" +version = "0.1.0" +dependencies = [ + "cbindgen 0.5.0", + "platform 0.1.0", +] + [[package]] name = "dtoa" version = "0.4.2" @@ -89,6 +97,14 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "grp" +version = "0.1.0" +dependencies = [ + "cbindgen 0.5.0", + "platform 0.1.0", +] + [[package]] name = "itoa" version = "0.3.4" @@ -212,7 +228,9 @@ name = "relibc" version = "0.1.0" dependencies = [ "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)", + "ctype 0.1.0", "fcntl 0.1.0", + "grp 0.1.0", "platform 0.1.0", "stdio 0.1.0", "stdlib 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index e84ea2cf048b358e965552e99c43cfd1790165fd..af003fd3368073b1cfb40c99dee92f8b439fe8e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,9 @@ members = ["crt0"] [dependencies] compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins.git", default-features = false, features = ["mem"] } platform = { path = "platform" } +ctype = { path = "src/ctype" } fcntl = { path = "src/fcntl" } +grp = { path = "src/grp" } stdio = { path = "src/stdio" } stdlib = { path = "src/stdlib" } string = { path = "src/string" } diff --git a/include/bits/wchar.h b/include/bits/wchar.h new file mode 100644 index 0000000000000000000000000000000000000000..98216dfb0fa5e22d686cd577f52e3fcd123faedf --- /dev/null +++ b/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 */ diff --git a/platform/src/types.rs b/platform/src/types.rs index bb87c740c01628af1778c0db142fc32ad83ed8ad..dbbc2be301c3e905c71be50f62de89ff4465bcb9 100644 --- a/platform/src/types.rs +++ b/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; diff --git a/src/ctype/Cargo.toml b/src/ctype/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..d0ae7b3fb39da74066d0b92668c74424df847f0d --- /dev/null +++ b/src/ctype/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "ctype" +version = "0.1.0" +authors = ["Jeremy Soller <jackpot51@gmail.com>"] +build = "build.rs" + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../../platform" } diff --git a/src/ctype/build.rs b/src/ctype/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..089fee8df3475623ed6d17be35e18db35120b2aa --- /dev/null +++ b/src/ctype/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/ctype.h"); +} diff --git a/src/ctype/cbindgen.toml b/src/ctype/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..db7a3a0bc8cc154671431a48bbf13af6964c7dee --- /dev/null +++ b/src/ctype/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = [] +include_guard = "_CTYPE_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/ctype/src/lib.rs b/src/ctype/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..be49d70ee46dfd9da76a229569754cdec7e51a29 --- /dev/null +++ b/src/ctype/src/lib.rs @@ -0,0 +1,82 @@ +//! ctype implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/ctype.h.html + +#![no_std] + +extern crate platform; + +use platform::types::*; + +#[no_mangle] +pub extern "C" fn isalnum(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isalpha(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isascii(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iscntrl(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isdigit(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isgraph(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn islower(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isprint(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn ispunct(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isspace(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isupper(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn isxdigit(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn toascii(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn tolower(c: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn toupper(c: c_int) -> c_int { + unimplemented!(); +} diff --git a/src/grp/Cargo.toml b/src/grp/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..d09fdca34c75d5b72ccd3031437b03ecc39fcea5 --- /dev/null +++ b/src/grp/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "grp" +version = "0.1.0" +authors = ["Jeremy Soller <jackpot51@gmail.com>"] +build = "build.rs" + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../../platform" } diff --git a/src/grp/build.rs b/src/grp/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..9ee6c696173144fdb709f8379162794a71f1cd0f --- /dev/null +++ b/src/grp/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/grp.h"); +} diff --git a/src/grp/cbindgen.toml b/src/grp/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..5b249723f82f9ed7a4f550344bbf3aa0562b2eaa --- /dev/null +++ b/src/grp/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = [] +include_guard = "_GRP_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/todo/grp/lib.rs b/src/grp/src/lib.rs similarity index 57% rename from src/todo/grp/lib.rs rename to src/grp/src/lib.rs index 3b7bbd403482f6a81f5a255720079a76c1876e7d..c80ee95affac19c1129deb0fdd339c2139efbb88 100644 --- a/src/todo/grp/lib.rs +++ b/src/grp/src/lib.rs @@ -1,24 +1,26 @@ -/* automatically generated by rust-bindgen */ +//! grp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/grp.h.html + +#![no_std] + +extern crate platform; + +use platform::types::*; + #[repr(C)] -#[derive(Debug, Copy)] pub struct group { - pub gr_name: *mut libc::c_char, - pub gr_passwd: *mut libc::c_char, + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, pub gr_gid: gid_t, - pub gr_mem: *mut *mut libc::c_char, -} -impl Clone for group { - fn clone(&self) -> Self { - *self - } + pub gr_mem: *mut *mut c_char, } + #[no_mangle] pub extern "C" fn getgrgid(gid: gid_t) -> *mut group { unimplemented!(); } #[no_mangle] -pub extern "C" fn getgrnam(name: *const libc::c_char) -> *mut group { +pub extern "C" fn getgrnam(name: *const c_char) -> *mut group { unimplemented!(); } @@ -26,21 +28,21 @@ pub extern "C" fn getgrnam(name: *const libc::c_char) -> *mut group { pub extern "C" fn getgrgid_r( gid: gid_t, grp: *mut group, - buffer: *mut libc::c_char, + buffer: *mut c_char, bufsize: usize, result: *mut *mut group, -) -> libc::c_int { +) -> c_int { unimplemented!(); } #[no_mangle] pub extern "C" fn getgrnam_r( - name: *const libc::c_char, + name: *const c_char, grp: *mut group, - buffer: *mut libc::c_char, + buffer: *mut c_char, bufsize: usize, result: *mut *mut group, -) -> libc::c_int { +) -> c_int { unimplemented!(); } @@ -58,3 +60,10 @@ pub extern "C" fn endgrent() { pub extern "C" fn setgrent() { unimplemented!(); } + +/* +#[no_mangle] +pub extern "C" fn func(args) -> c_int { + unimplemented!(); +} +*/ diff --git a/src/lib.rs b/src/lib.rs index 0e043802550d5a6bd1d261b61b3a3d59dfb25055..63815d70bec90d5669db6f7c01f6a00e4504c203 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,9 @@ extern crate compiler_builtins; extern crate platform; +extern crate ctype; extern crate fcntl; +extern crate grp; extern crate stdio; extern crate stdlib; extern crate string; diff --git a/src/template/Cargo.toml b/src/template/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..4021963f1f529cac673f398c4b1d6de87280f5c6 --- /dev/null +++ b/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" } diff --git a/src/template/build.rs b/src/template/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..35b5d3bd872438fabe697c71cfab5de13dac60bc --- /dev/null +++ b/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"); +} diff --git a/src/template/cbindgen.toml b/src/template/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..bf4ccefceda1d5b41b72d0dee832a2b8fde6e7d1 --- /dev/null +++ b/src/template/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = [] +include_guard = "_TEMPLATE_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/template/src/lib.rs b/src/template/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..e0c83c7cef6b09ba428d036c27b923657416048b --- /dev/null +++ b/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!(); +} +*/ diff --git a/src/todo/ctype/lib.rs b/src/todo/ctype/lib.rs deleted file mode 100644 index 4d83de3f899d5167f5bbc914285ba533931a2d54..0000000000000000000000000000000000000000 --- a/src/todo/ctype/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#[no_mangle] -pub extern "C" fn isalnum(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isalpha(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isascii(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn iscntrl(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isdigit(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isgraph(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn islower(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isprint(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn ispunct(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isspace(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isupper(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn isxdigit(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn toascii(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn tolower(c: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn toupper(c: libc::c_int) -> libc::c_int { - unimplemented!(); -}