Skip to content

Commit 9c14d89

Browse files
committed
Auto merge of #10 - skade:move-to-stable, r=hobofan
Move to stable This PR removes unnecessary use of feature flags that bar using Rust on stable([1])([2]) compilers. Reasons being: * associated consts (Tracking issue: rust-lang/rust#29646) are currently buggy and can be replaced by an fn in that case. * associated_type_defaults can be removed without breakage * unboxed_closures can be removed without breakage * StaticMutex has an uncertain future (rust-lang/rust#27717) and can be emulated in that case by using `lazy_static!` (correct me if I'm wrong) Finally, I must admit that I didn't get the test suite running quickly. ([1]) Outstanding: this doesn't _quite_ work on stable yet, as some APIs in use are currently making their way through beta, so they are not feature gated, but also not available in 1.4.0. 1.5.0 beta works and as 1.5.0 is 2 weeks away, this is probably not worth the effort. ([2]) rblas is not on stable yet, see mikkyang/rust-blas#12 for that. You can use that version of rust-blas by checking it out from my https://github.com/skade/rust-blas/ and dropping the following `.cargo/config` in your repository: ``` paths = ["/path/to/rblas/checkout"] ```
2 parents 75514ee + f14c1fc commit 9c14d89

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ license = "MIT"
1717
[dependencies]
1818
libc = "0.2"
1919
bitflags = "0.3"
20-
rblas = "0.0.10"
20+
rblas = "0.0.11"
2121
enum_primitive = "0.1.0"
2222
byteorder = "0.4"
2323
num = "0.1"
24+
lazy_static = "0.1.15"
2425

2526
clippy = { version = "0.0.27", optional = true }
2627

src/framework.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ pub trait IFramework {
3838
///
3939
/// For convention, let the ID be uppercase.<br/>
4040
/// EXAMPLE: OPENCL
41-
const ID: &'static str;
41+
#[allow(non_snake_case)]
42+
fn ID() -> &'static str;
4243

4344
/// Initializes a new Framework.
4445
///

src/frameworks/cuda/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ impl IFramework for Cuda {
3636
type H = Device;
3737
type D = Context;
3838
type B = Module;
39-
const ID: &'static str = "CUDA";
39+
40+
fn ID() -> &'static str { "CUDA" }
4041

4142
fn new() -> Cuda {
4243
match Cuda::load_hardwares() {

src/frameworks/native/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl IFramework for Native {
4040
type D = Cpu;
4141
type B = Binary;
4242

43-
const ID: &'static str = "NATIVE";
43+
fn ID() -> &'static str { "NATIVE" }
4444

4545
fn new() -> Native {
4646
match Native::load_hardwares() {

src/frameworks/opencl/api/platform.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::types as cl;
66
use super::ffi::*;
77
use std::ptr;
88
use std::iter::repeat;
9-
use std::sync::{StaticMutex, MUTEX_INIT};
9+
use std::sync::Mutex;
1010

1111
impl API {
1212
/// Returns a list of available platforms.
@@ -22,7 +22,9 @@ impl API {
2222
// This mutex is used to work around weak OpenCL implementations.
2323
// On some implementations concurrent calls to clGetPlatformIDs
2424
// will cause the implantation to return invalid status.
25-
static mut platforms_mutex: StaticMutex = MUTEX_INIT;
25+
lazy_static! {
26+
static ref platforms_mutex: Mutex<()> = Mutex::new(());
27+
}
2628

2729
let guard = unsafe {platforms_mutex.lock()};
2830
try!(unsafe {API::ffi_get_platform_ids(0, ptr::null_mut(), (&mut num_platforms))});

src/frameworks/opencl/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl IFramework for OpenCL {
5050
type H = Device;
5151
type D = Context;
5252
type B = Program;
53-
const ID: &'static str = "OPENCL";
53+
54+
fn ID() -> &'static str { "OPENCL" }
5455

5556
fn new() -> OpenCL {
5657
match OpenCL::load_hardwares() {

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@
134134
#![cfg_attr(lint, feature(plugin))]
135135
#![cfg_attr(lint, plugin(clippy))]
136136
#![allow(dead_code)]
137-
#![feature(associated_consts)]
138-
#![feature(associated_type_defaults)]
139-
#![feature(unboxed_closures)]
140-
#![feature(static_mutex)]
141137
#![deny(missing_docs,
142138
missing_debug_implementations, missing_copy_implementations,
143139
trivial_casts, trivial_numeric_casts,
@@ -148,6 +144,8 @@ extern crate libc;
148144
extern crate bitflags;
149145
#[macro_use]
150146
extern crate enum_primitive;
147+
#[macro_use]
148+
extern crate lazy_static;
151149
extern crate num;
152150
extern crate byteorder;
153151
extern crate rblas as blas;

0 commit comments

Comments
 (0)