From c4b88cc1e63acb83bccd492c1b9e320af8edbad7 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Sat, 3 Mar 2018 20:33:19 -0700 Subject: [PATCH] Build ctype with header --- Cargo.lock | 9 +++++ Cargo.toml | 1 + src/ctype/Cargo.toml | 11 ++++++ src/ctype/build.rs | 11 ++++++ src/ctype/cbindgen.toml | 6 +++ src/ctype/src/lib.rs | 82 +++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + src/todo/ctype/lib.rs | 76 -------------------------------------- 8 files changed, 121 insertions(+), 76 deletions(-) create mode 100644 src/ctype/Cargo.toml create mode 100644 src/ctype/build.rs create mode 100644 src/ctype/cbindgen.toml create mode 100644 src/ctype/src/lib.rs delete mode 100644 src/todo/ctype/lib.rs diff --git a/Cargo.lock b/Cargo.lock index a485ed6ca..60bc0e45a 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" @@ -212,6 +220,7 @@ 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", "platform 0.1.0", "stdio 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index e84ea2cf0..d012812b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ 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" } stdio = { path = "src/stdio" } stdlib = { path = "src/stdlib" } diff --git a/src/ctype/Cargo.toml b/src/ctype/Cargo.toml new file mode 100644 index 000000000..d0ae7b3fb --- /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 000000000..089fee8df --- /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 000000000..db7a3a0bc --- /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 000000000..be49d70ee --- /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/lib.rs b/src/lib.rs index 0e0438025..d1cdd8af0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ extern crate compiler_builtins; extern crate platform; +extern crate ctype; extern crate fcntl; extern crate stdio; extern crate stdlib; diff --git a/src/todo/ctype/lib.rs b/src/todo/ctype/lib.rs deleted file mode 100644 index 4d83de3f8..000000000 --- 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!(); -} -- GitLab