Implement argument handling, add string.h

This commit is contained in:
Jeremy Soller
2018-03-03 14:55:54 -07:00
parent 78e421cb72
commit 2aff4d41dd
15 changed files with 132 additions and 27 deletions
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "string"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../cbindgen" }
[dependencies]
platform = { path = "../platform" }
+11
View File
@@ -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/string.h");
}
+6
View File
@@ -0,0 +1,6 @@
sys_includes = ["stddef.h"]
include_guard = "_STRING_H"
language = "C"
[enum]
prefix_with_name = true
+28
View File
@@ -0,0 +1,28 @@
//! string implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/string.h.html
#![no_std]
extern crate platform;
use platform::types::*;
#[no_mangle]
pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t {
let mut size = 0;
loop {
if *s.offset(size) == 0 {
break;
}
size += 1;
}
size as size_t
}
/*
#[no_mangle]
pub extern "C" fn func(args) -> c_int {
unimplemented!();
}
*/