forked from kaidokert/num-traits
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copysign (upstream PR rust-num#207)
Signed-off-by: Fredrick Brennan <copypaste@kittens.ph>
- Loading branch information
1 parent
1d194de
commit c264006
Showing
3 changed files
with
65 additions
and
39 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 |
---|---|---|
|
@@ -27,6 +27,7 @@ std = [] | |
|
||
# vestigial features, now always in effect | ||
i128 = [] | ||
copysign = [] | ||
|
||
[build-dependencies] | ||
autocfg = "1" |
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,20 +1,27 @@ | ||
extern crate autocfg; | ||
|
||
use std::env; | ||
|
||
fn main() { | ||
let ac = autocfg::new(); | ||
|
||
// If the "i128" feature is explicity requested, don't bother probing for it. | ||
// It will still cause a build error if that was set improperly. | ||
if env::var_os("CARGO_FEATURE_I128").is_some() || ac.probe_type("i128") { | ||
autocfg::emit("has_i128"); | ||
} | ||
|
||
if env::var_os("CARGO_FEATURE_COPYSIGN").is_some() || ac.probe_expression("f32::copysign") { | ||
autocfg::emit("has_copysign"); | ||
} | ||
|
||
ac.emit_expression_cfg( | ||
"unsafe { 1f64.to_int_unchecked::<i32>() }", | ||
"has_to_int_unchecked", | ||
); | ||
|
||
ac.emit_expression_cfg("1u32.reverse_bits()", "has_reverse_bits"); | ||
ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones"); | ||
ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid"); | ||
|
||
if env::var_os("CARGO_FEATURE_STD").is_some() { | ||
ac.emit_expression_cfg("1f64.copysign(-1f64)", "has_copysign"); | ||
} | ||
|
||
autocfg::rerun_path("build.rs"); | ||
} |
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