Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libc + tlibc works for memory mapping functions.
- Loading branch information
1 parent
fffda85
commit d0fbcd0
Showing
19 changed files
with
1,184 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
authors = ["Kevin Boos <kevinaboos@gmail.com>"] | ||
name = "test_libc" | ||
description = "A crate for testing tlibc with the libc Rust crate ported to Theseus" | ||
version = "0.1.0" | ||
build = "../../build.rs" | ||
|
||
[dependencies] | ||
log = "0.4.8" | ||
libc = { version = "0.2", default-features = false } | ||
|
||
|
||
[lib] | ||
crate-type = ["rlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! A simple test crate for trying to build and use libc from Rust in Theseus. | ||
//! | ||
//! This involves a ported version of the Rust libc crate that must be built in a way | ||
//! that uses Theseus's `tlibc` as the underlying libc implementation. | ||
|
||
#![no_std] | ||
|
||
use core::ptr; | ||
|
||
use alloc::{vec::Vec, string::String}; | ||
|
||
extern crate alloc; | ||
#[macro_use] extern crate log; | ||
extern crate libc; | ||
|
||
|
||
pub fn main(_args: Vec<String>) -> isize { | ||
test_mmap(); | ||
test_printf(); | ||
0 | ||
} | ||
|
||
fn test_mmap() { | ||
warn!("Hello from test_mmap()"); | ||
let ret = unsafe { | ||
libc::mmap(ptr::null_mut(), 100, 0, 0, 0, 0) | ||
}; | ||
warn!("test_mmap: mmap returned {:?}", ret); | ||
} | ||
|
||
|
||
fn test_printf() { | ||
warn!("Hello from test_printf()"); | ||
let ret = unsafe { | ||
libc::printf(b"%d".as_ptr() as *const i8, 17); | ||
}; | ||
warn!("test_printf: printf returned {:?}", ret); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
Oops, something went wrong.