Skip to content

Commit

Permalink
Auto merge of #646 - FenrirWolf:newlib, r=alexcrichton
Browse files Browse the repository at this point in the history
Add experimental newlib bindings

I'm not sure how much desire there is for something like this in the libc crate, but I've been working with a newlib-based toolchain for a while and thought I'd throw this PR up and see what happens.

These bindings are more specifically targeted towards the devkitARM toolchain from http://devkitpro.org rather than newlib in general. I'd be happy to try making things more platform and toolchain-agnostic, but I'm not completely sure what the best way to do that is. I can move more of the arch-specific bindings to the `arm` folder, but should there also be a `devkitarm` subdirectory to further separate specific bindings from other newlib implementations?

There's also the question of if the bindings should live in the `unix` directory in the first place. Newlib aims to provide a unix/posix-like environment and it would be nice to inherit common unix definitions by default, but it can target anything from embedded devices to custom userlands, and as such it often lacks APIs that are common in other libc variants, such as pthreads.
  • Loading branch information
bors committed Jul 6, 2017
2 parents 3056418 + 91f6673 commit 375d773
Show file tree
Hide file tree
Showing 3 changed files with 616 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ cfg_if! {
#[link(name = "c")]
#[link(name = "mxio")]
extern {}
} else if #[cfg(target_env = "newlib")] {
#[link(name = "c")]
#[link(name = "m")]
extern {}
} else {
#[link(name = "c")]
#[link(name = "m")]
Expand Down Expand Up @@ -888,6 +892,9 @@ cfg_if! {
if #[cfg(target_env = "uclibc")] {
mod uclibc;
pub use self::uclibc::*;
} else if #[cfg(target_env = "newlib")] {
mod newlib;
pub use self::newlib::*;
} else if #[cfg(any(target_os = "linux",
target_os = "android",
target_os = "emscripten",
Expand Down
5 changes: 5 additions & 0 deletions src/unix/newlib/arm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub type c_char = u8;
pub type wchar_t = u32;

pub type c_long = i32;
pub type c_ulong = u32;
Loading

0 comments on commit 375d773

Please sign in to comment.