Skip to content

Commit 375d773

Browse files
committed
Auto merge of rust-lang#646 - FenrirWolf:newlib, r=alexcrichton
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.
2 parents 3056418 + 91f6673 commit 375d773

File tree

3 files changed

+616
-0
lines changed

3 files changed

+616
-0
lines changed

src/unix/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ cfg_if! {
252252
#[link(name = "c")]
253253
#[link(name = "mxio")]
254254
extern {}
255+
} else if #[cfg(target_env = "newlib")] {
256+
#[link(name = "c")]
257+
#[link(name = "m")]
258+
extern {}
255259
} else {
256260
#[link(name = "c")]
257261
#[link(name = "m")]
@@ -888,6 +892,9 @@ cfg_if! {
888892
if #[cfg(target_env = "uclibc")] {
889893
mod uclibc;
890894
pub use self::uclibc::*;
895+
} else if #[cfg(target_env = "newlib")] {
896+
mod newlib;
897+
pub use self::newlib::*;
891898
} else if #[cfg(any(target_os = "linux",
892899
target_os = "android",
893900
target_os = "emscripten",

src/unix/newlib/arm/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub type c_char = u8;
2+
pub type wchar_t = u32;
3+
4+
pub type c_long = i32;
5+
pub type c_ulong = u32;

0 commit comments

Comments
 (0)