File tree 4 files changed +33
-14
lines changed
4 files changed +33
-14
lines changed Original file line number Diff line number Diff line change @@ -470,10 +470,7 @@ impl f32 {
470
470
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
471
471
#[ inline]
472
472
pub fn log2 ( self ) -> f32 {
473
- #[ cfg( target_os = "android" ) ]
474
- return crate :: sys:: android:: log2f32 ( self ) ;
475
- #[ cfg( not( target_os = "android" ) ) ]
476
- return unsafe { intrinsics:: log2f32 ( self ) } ;
473
+ return crate :: sys:: log2f32 ( self ) ;
477
474
}
478
475
479
476
/// Returns the base 10 logarithm of the number.
Original file line number Diff line number Diff line change @@ -470,12 +470,7 @@ impl f64 {
470
470
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
471
471
#[ inline]
472
472
pub fn log2 ( self ) -> f64 {
473
- self . log_wrapper ( |n| {
474
- #[ cfg( target_os = "android" ) ]
475
- return crate :: sys:: android:: log2f64 ( n) ;
476
- #[ cfg( not( target_os = "android" ) ) ]
477
- return unsafe { intrinsics:: log2f64 ( n) } ;
478
- } )
473
+ self . log_wrapper ( crate :: sys:: log2f64)
479
474
}
480
475
481
476
/// Returns the base 10 logarithm of the number.
@@ -936,8 +931,8 @@ impl f64 {
936
931
// of expected NaN).
937
932
#[ rustc_allow_incoherent_impl]
938
933
fn log_wrapper < F : Fn ( f64 ) -> f64 > ( self , log_fn : F ) -> f64 {
939
- if ! cfg ! ( any ( target_os = "solaris" , target_os = "illumos" ) ) {
940
- log_fn ( self )
934
+ if let Some ( result ) = crate :: sys :: log_wrapper ( self ) {
935
+ log_fn ( result )
941
936
} else if self . is_finite ( ) {
942
937
if self > 0.0 {
943
938
log_fn ( self )
Original file line number Diff line number Diff line change @@ -76,3 +76,32 @@ cfg_if::cfg_if! {
76
76
pub mod c;
77
77
}
78
78
}
79
+
80
+ #[ cfg( not( test) ) ]
81
+ cfg_if:: cfg_if! {
82
+ if #[ cfg( target_os = "android" ) ] {
83
+ pub use crate :: android:: log2f32;
84
+ pub use crate :: android:: log2f64;
85
+ } else {
86
+ pub fn log2f32( n: f32 ) -> f32 {
87
+ unsafe { crate :: intrinsics:: log2f32( n) }
88
+ }
89
+
90
+ pub fn log2f64( n: f64 ) -> f64 {
91
+ unsafe { crate :: intrinsics:: log2f64( n) }
92
+ }
93
+ }
94
+ }
95
+
96
+ #[ cfg( not( test) ) ]
97
+ cfg_if:: cfg_if! {
98
+ if #[ cfg( any( target_os = "solaris" , target_os = "illumos" ) ) ] {
99
+ pub fn log_wrapper( n: f64 ) -> Option <f64 > {
100
+ Some ( n)
101
+ }
102
+ } else {
103
+ pub fn log_wrapper( _n: f64 ) -> Option <f64 > {
104
+ None
105
+ }
106
+ }
107
+ }
Original file line number Diff line number Diff line change @@ -54,8 +54,6 @@ const EXCEPTION_PATHS: &[&str] = &[
54
54
// FIXME: platform-specific code should be moved to `sys`
55
55
"library/std/src/io/copy.rs" ,
56
56
"library/std/src/io/stdio.rs" ,
57
- "library/std/src/f32.rs" ,
58
- "library/std/src/f64.rs" ,
59
57
"library/std/src/path.rs" ,
60
58
"library/std/src/sys_common" , // Should only contain abstractions over platforms
61
59
"library/std/src/net/test.rs" , // Utility helpers for tests
You can’t perform that action at this time.
0 commit comments