Skip to content

Commit

Permalink
Deny all warnings and fix errors (rust-lang#135)
Browse files Browse the repository at this point in the history
* [travis-ci] deny warnings

* fix all warnings
  • Loading branch information
gnzlbg authored and alexcrichton committed Oct 22, 2017
1 parent 077f1f7 commit 6fdfce5
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 39 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ opt-level = 3
[dev-dependencies]
stdsimd-test = { path = "stdsimd-test" }
cupid = "0.3"

[features]
strict = []
4 changes: 2 additions & 2 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ esac

echo "RUSTFLAGS=${RUSTFLAGS}"

cargo test --target $TARGET
cargo test --release --target $TARGET
cargo test --target $TARGET --features "strict"
cargo test --release --target $TARGET --features "strict"
60 changes: 31 additions & 29 deletions examples/nbody.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(cfg_target_feature)]
#![feature(target_feature)]

extern crate stdsimd;

use self::stdsimd::simd;
use self::stdsimd::vendor;

use simd::{f64x2, f32x4};
use simd::f64x2;

const PI: f64 = 3.141592653589793;
const SOLAR_MASS: f64 = 4.0 * PI * PI;
Expand All @@ -18,31 +16,35 @@ pub trait Frsqrt {

impl Frsqrt for f64x2 {
fn frsqrt(&self) -> Self {
unsafe {
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse"))]
{
let t = self.as_f32x2();
let u = vendor::_mm_rsqrt_ps(
f32x4::new(t.extract(0), t.extract(1), 0., 0.)).as_f64x4();
f64x2::new(u.extract(0), u.extract(1))
}
#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"),
target_feature = "neon"))]
{
vendor::vrsqrte_f32(self.as_f32x2()).as_f64x2()
}

#[cfg(not(any(all(any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse"),
all(any(target_arch = "arm", target_arch = "aarch64"),
target_feature = "neon")
)))]
{
self.replace(0, 1. / self.extract(0).sqrt());
self.replace(1, 1. / self.extract(1).sqrt());
*self
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse"))]
{
use self::stdsimd::vendor;
use simd::f32x4;

let t = self.as_f32x2();

let u = unsafe {
vendor::_mm_rsqrt_ps(
f32x4::new(t.extract(0), t.extract(1), 0., 0.)).as_f64x4()
};
f64x2::new(u.extract(0), u.extract(1))
}
#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"),
target_feature = "neon"))]
{
use self::stdsimd::vendor;
unsafe { vendor::vrsqrte_f32(self.as_f32x2()).as_f64x2() }
}
#[cfg(not(any(all(any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse"),
all(any(target_arch = "arm", target_arch = "aarch64"),
target_feature = "neon")
)))]
{
self.replace(0, 1. / self.extract(0).sqrt());
self.replace(1, 1. / self.extract(1).sqrt());
*self
}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/play.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(target_feature)]

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
1 change: 1 addition & 0 deletions examples/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(target_feature)]

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
1 change: 1 addition & 0 deletions examples/wat.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(target_feature)]

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
2 changes: 0 additions & 2 deletions src/arm/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub unsafe fn vrsqrte_f32(a: f32x2) -> f32x2 {

#[cfg(test)]
mod tests {
use stdsimd_test::simd_test;

use v64::{f32x2};
use arm::neon;

Expand Down
2 changes: 0 additions & 2 deletions src/arm/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub unsafe fn _rev_u32(x: u32) -> u32 {

#[cfg(test)]
mod tests {
use stdsimd_test::simd_test;

use arm::v6;

#[test]
Expand Down
2 changes: 0 additions & 2 deletions src/arm/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extern "C" {

#[cfg(test)]
mod tests {
use stdsimd_test::simd_test;

use arm::v7;

#[test]
Expand Down
2 changes: 0 additions & 2 deletions src/arm/v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ pub unsafe fn _cls_u64(x: u64) -> u64 {

#[cfg(test)]
mod tests {
use stdsimd_test::simd_test;

use arm::v8;

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
//!
//! [vendor]: https://github.com/rust-lang-nursery/stdsimd/issues/40

#![cfg_attr(feature = "strict", deny(warnings))]
#![allow(dead_code)]
#![allow(unused_features)]
#![feature(
Expand Down
2 changes: 2 additions & 0 deletions tests/cpu-detection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(cfg_target_feature)]

#[macro_use]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
extern crate stdsimd;
extern crate cupid;

Expand Down

0 comments on commit 6fdfce5

Please sign in to comment.