2016-08-07 15:58:05 -05:00
|
|
|
#![feature(asm)]
|
2016-08-15 21:08:04 -05:00
|
|
|
#![feature(core_intrinsics)]
|
2016-08-12 21:20:56 -05:00
|
|
|
#![feature(linkage)]
|
2016-08-07 15:58:05 -05:00
|
|
|
#![feature(naked_functions)]
|
2016-08-13 16:58:44 -05:00
|
|
|
#![cfg_attr(not(test), no_std)]
|
2016-08-13 12:16:52 -05:00
|
|
|
#![no_builtins]
|
2016-08-07 15:58:05 -05:00
|
|
|
// TODO(rust-lang/rust#35021) uncomment when that PR lands
|
|
|
|
|
// #![feature(rustc_builtins)]
|
|
|
|
|
|
2016-08-13 09:51:54 +01:00
|
|
|
// We disable #[no_mangle] for tests so that we can verify the test results
|
|
|
|
|
// against the native compiler-rt implementations of the builtins.
|
|
|
|
|
|
2016-09-26 15:55:11 -05:00
|
|
|
// NOTE cfg(all(feature = "c", ..)) indicate that compiler-rt provides an arch optimized
|
|
|
|
|
// implementation of that intrinsic and we'll prefer to use that
|
|
|
|
|
|
2016-10-07 17:48:37 -05:00
|
|
|
// TODO(rust-lang/rust#37029) use e.g. checked_div(_).unwrap_or_else(|| abort())
|
2016-10-07 10:17:44 -05:00
|
|
|
macro_rules! udiv {
|
|
|
|
|
($a:expr, $b:expr) => {
|
|
|
|
|
unsafe {
|
|
|
|
|
let a = $a;
|
|
|
|
|
let b = $b;
|
|
|
|
|
|
|
|
|
|
if b == 0 {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::abort()
|
2016-10-07 10:17:44 -05:00
|
|
|
} else {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::unchecked_div(a, b)
|
2016-10-07 10:17:44 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! sdiv {
|
|
|
|
|
($sty:ident, $a:expr, $b:expr) => {
|
|
|
|
|
unsafe {
|
|
|
|
|
let a = $a;
|
|
|
|
|
let b = $b;
|
|
|
|
|
|
|
|
|
|
if b == 0 || (b == -1 && a == $sty::min_value()) {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::abort()
|
2016-10-07 10:17:44 -05:00
|
|
|
} else {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::unchecked_div(a, b)
|
2016-10-07 10:17:44 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! urem {
|
|
|
|
|
($a:expr, $b:expr) => {
|
|
|
|
|
unsafe {
|
|
|
|
|
let a = $a;
|
|
|
|
|
let b = $b;
|
|
|
|
|
|
|
|
|
|
if b == 0 {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::abort()
|
2016-10-07 10:17:44 -05:00
|
|
|
} else {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::unchecked_rem(a, b)
|
2016-10-07 10:17:44 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! srem {
|
|
|
|
|
($sty:ty, $a:expr, $b:expr) => {
|
|
|
|
|
unsafe {
|
|
|
|
|
let a = $a;
|
|
|
|
|
let b = $b;
|
|
|
|
|
|
|
|
|
|
if b == 0 || (b == -1 && a == $sty::min_value()) {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::abort()
|
2016-10-07 10:17:44 -05:00
|
|
|
} else {
|
2016-10-07 17:48:37 -05:00
|
|
|
::core::intrinsics::unchecked_rem(a, b)
|
2016-10-07 10:17:44 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 19:12:37 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate quickcheck;
|
2016-08-07 15:58:05 -05:00
|
|
|
|
2016-08-13 16:58:44 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
|
extern crate core;
|
|
|
|
|
|
2016-09-16 15:53:14 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
|
extern crate gcc_s;
|
|
|
|
|
|
2016-09-26 22:22:10 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
|
extern crate compiler_rt;
|
|
|
|
|
|
2016-09-21 21:38:06 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
|
extern crate rand;
|
|
|
|
|
|
2016-09-22 14:46:05 -05:00
|
|
|
#[cfg(feature = "weak")]
|
2016-08-14 21:59:48 -05:00
|
|
|
extern crate rlibc;
|
|
|
|
|
|
2016-09-26 22:22:10 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
|
#[macro_use]
|
|
|
|
|
mod qc;
|
|
|
|
|
|
2016-08-17 15:50:24 -05:00
|
|
|
pub mod int;
|
2016-08-17 15:51:37 -05:00
|
|
|
pub mod float;
|
2016-08-17 15:50:24 -05:00
|
|
|
|
2016-08-07 15:58:05 -05:00
|
|
|
#[cfg(target_arch = "arm")]
|
|
|
|
|
pub mod arm;
|
|
|
|
|
|
2016-08-16 17:46:46 -05:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
|
pub mod x86_64;
|