From e05caa122755cc7a25cb5fe895442b1416fabf61 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 10 Oct 2016 19:45:34 -0500 Subject: [PATCH] fix warnings --- ci/run.sh | 4 +++- src/bin/intrinsics.rs | 3 ++- src/int/sdiv.rs | 7 ++++++- src/int/udiv.rs | 16 ++++++++++++++-- src/lib.rs | 4 ++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 3846049..90441bd 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -1,4 +1,6 @@ -set -e +set -ex + +export RUST_BACKTRACE=1 # Test our implementation case $1 in diff --git a/src/bin/intrinsics.rs b/src/bin/intrinsics.rs index e11e415..db6d7d9 100644 --- a/src/bin/intrinsics.rs +++ b/src/bin/intrinsics.rs @@ -7,6 +7,7 @@ #![cfg_attr(thumb, no_main)] #![deny(dead_code)] #![feature(asm)] +#![feature(compiler_builtins_lib)] #![feature(core_float)] #![feature(lang_items)] #![feature(libc)] @@ -15,7 +16,7 @@ #[cfg(not(thumb))] extern crate libc; -extern crate rustc_builtins; +extern crate compiler_builtins; // NOTE cfg(not(thumbv6m)) means that the operation is not supported on ARMv6-M at all. Not even // compiler-rt provides a C/assembly implementation. diff --git a/src/int/sdiv.rs b/src/int/sdiv.rs index a1d119f..b541322 100644 --- a/src/int/sdiv.rs +++ b/src/int/sdiv.rs @@ -43,7 +43,12 @@ macro_rules! divmod { fn $div(a: $ty, b: $ty) -> $ty; } - let r = unsafe { $div(a, b) }; + let r = match () { + #[cfg(not(all(feature = "c", any(target_arch = "x86"))))] + () => $div(a, b), + #[cfg(all(feature = "c", any(target_arch = "x86")))] + () => unsafe { $div(a, b) }, + }; *rem = a - (r * b); r } diff --git a/src/int/udiv.rs b/src/int/udiv.rs index 999dcec..4a14d3c 100644 --- a/src/int/udiv.rs +++ b/src/int/udiv.rs @@ -65,7 +65,14 @@ pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 { fn __udivsi3(n: u32, d: u32) -> u32; } - n - unsafe { __udivsi3(n, d) * d } + let q = match () { + #[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios")))] + () => unsafe { __udivsi3(n, d) }, + #[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"))))] + () => __udivsi3(n, d), + }; + + n - q * d } /// Returns `n / d` and sets `*rem = n % d` @@ -77,7 +84,12 @@ pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 { fn __udivsi3(n: u32, d: u32) -> u32; } - let q = unsafe { __udivsi3(n, d) }; + let q = match () { + #[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios")))] + () => unsafe { __udivsi3(n, d) }, + #[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"))))] + () => __udivsi3(n, d), + }; if let Some(rem) = rem { *rem = n - (q * d); } diff --git a/src/lib.rs b/src/lib.rs index bcc56e5..0efb20b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(stage0), deny(warnings))] #![cfg_attr(not(test), no_std)] -#![compiler_builtins] +#![cfg_attr(rustbuild, compiler_builtins)] #![crate_name = "compiler_builtins"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", @@ -15,7 +15,7 @@ #![feature(naked_functions)] #![feature(staged_api)] #![no_builtins] -#![unstable(feature = "compiler_builtins", +#![unstable(feature = "compiler_builtins_lib", reason = "Compiler builtins. Will never become stable.", issue = "0")]