-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #67 - japaric:gcc_s, r=japaric
test our implementations against gcc_s if it exposes the same intrinsics that we implement -- gcc_s doesn't implement all the intrinsics for all the architectures. closes #65 r? @Amanieu Tested on Linux x86_64 and against the x86_64 and the arm-gnueabi targets. Unclear whether this works on osx or windows.
- Loading branch information
Showing
10 changed files
with
292 additions
and
27 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
[package] | ||
authors = ["Jorge Aparicio <[email protected]>"] | ||
build = "build.rs" | ||
name = "rustc_builtins" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
rlibc = { git = "https://github.com/alexcrichton/rlibc", optional = true } | ||
|
||
[dependencies.rlibc] | ||
git = "https://github.com/alexcrichton/rlibc" | ||
optional = true | ||
|
||
[dev-dependencies] | ||
quickcheck = "0.3.1" | ||
rand = "0.3.14" | ||
|
||
[dev-dependencies.gcc_s] | ||
path = "gcc_s" | ||
|
||
[features] | ||
default = ["rlibc/weak"] | ||
|
||
[workspace] |
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,7 @@ | ||
use std::env; | ||
|
||
fn main() { | ||
if env::var("TARGET").unwrap().ends_with("gnueabihf") { | ||
println!("cargo:rustc-cfg=gnueabihf") | ||
} | ||
} |
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,7 @@ | ||
[package] | ||
authors = ["Jorge Aparicio <[email protected]>"] | ||
name = "gcc_s" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
libloading = "0.3.0" |
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,68 @@ | ||
#![feature(drop_types_in_const)] | ||
|
||
extern crate libloading; | ||
|
||
use std::sync::{Once, ONCE_INIT}; | ||
|
||
use libloading::Library; | ||
|
||
static mut GCC_S: Option<Library> = None; | ||
|
||
#[cfg(not(windows))] | ||
fn gcc_s() -> &'static Library { | ||
#[cfg(not(target_os = "macos"))] | ||
const LIBGCC_S: &'static str = "libgcc_s.so.1"; | ||
|
||
#[cfg(target_os = "macos")] | ||
const LIBGCC_S: &'static str = "libgcc_s.1.dylib"; | ||
|
||
unsafe { | ||
static INIT: Once = ONCE_INIT; | ||
|
||
INIT.call_once(|| { | ||
GCC_S = Some(Library::new(LIBGCC_S).unwrap()); | ||
}); | ||
GCC_S.as_ref().unwrap() | ||
} | ||
} | ||
|
||
#[cfg(windows)] | ||
macro_rules! declare { | ||
($symbol:ident: fn($($i:ty),+) -> $o:ty) => { | ||
pub fn $symbol() -> Option<unsafe extern fn($($i),+) -> $o> { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(windows))] | ||
macro_rules! declare { | ||
($symbol:ident: fn($($i:ty),+) -> $o:ty) => { | ||
pub fn $symbol() -> Option<unsafe extern fn($($i),+) -> $o> { | ||
unsafe { | ||
gcc_s().get(concat!("__", stringify!($symbol)).as_bytes()).ok().map(|s| *s) | ||
} | ||
} | ||
} | ||
} | ||
|
||
declare!(ashldi3: fn(u64, u32) -> u64); | ||
declare!(ashrdi3: fn(i64, u32) -> i64); | ||
declare!(divdi3: fn(i64, i64) -> i64); | ||
declare!(divmoddi4: fn(i64, i64, &mut i64) -> i64); | ||
declare!(divmodsi4: fn(i32, i32, &mut i32) -> i32); | ||
declare!(divsi3: fn(i32, i32) -> i32); | ||
declare!(lshrdi3: fn(u64, u32) -> u64); | ||
declare!(moddi3: fn(i64, i64) -> i64); | ||
declare!(modsi3: fn(i32, i32) -> i32); | ||
declare!(muldi3: fn(u64, u64) -> u64); | ||
declare!(mulodi4: fn(i64, i64, &mut i32) -> i64); | ||
declare!(mulosi4: fn(i32, i32, &mut i32) -> i32); | ||
declare!(udivdi3: fn(u64, u64) -> u64); | ||
declare!(udivmoddi4: fn(u64, u64, Option<&mut u64>) -> u64); | ||
declare!(udivmodsi4: fn(u32, u32, Option<&mut u32>) -> u32); | ||
declare!(udivsi3: fn(u32, u32) -> u32); | ||
declare!(umoddi3: fn(u64, u64) -> u64); | ||
declare!(umodsi3: fn(u32, u32) -> u32); | ||
declare!(addsf3: fn(f32, f32) -> f32); | ||
declare!(adddf3: fn(f64, f64) -> f64); |
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
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
Oops, something went wrong.