@@ -84,44 +84,54 @@ mod cmath {
84
84
mod shims {
85
85
use libc:: { c_float, c_int} ;
86
86
87
+ #[ inline]
87
88
pub unsafe fn acosf ( n : c_float ) -> c_float {
88
89
f64:: acos ( n as f64 ) as c_float
89
90
}
90
91
92
+ #[ inline]
91
93
pub unsafe fn asinf ( n : c_float ) -> c_float {
92
94
f64:: asin ( n as f64 ) as c_float
93
95
}
94
96
97
+ #[ inline]
95
98
pub unsafe fn atan2f ( n : c_float , b : c_float ) -> c_float {
96
99
f64:: atan2 ( n as f64 , b as f64 ) as c_float
97
100
}
98
101
102
+ #[ inline]
99
103
pub unsafe fn atanf ( n : c_float ) -> c_float {
100
104
f64:: atan ( n as f64 ) as c_float
101
105
}
102
106
107
+ #[ inline]
103
108
pub unsafe fn coshf ( n : c_float ) -> c_float {
104
109
f64:: cosh ( n as f64 ) as c_float
105
110
}
106
111
112
+ #[ inline]
107
113
pub unsafe fn frexpf ( x : c_float , value : & mut c_int ) -> c_float {
108
114
let ( a, b) = f64:: frexp ( x as f64 ) ;
109
115
* value = b as c_int ;
110
116
a as c_float
111
117
}
112
118
119
+ #[ inline]
113
120
pub unsafe fn ldexpf ( x : c_float , n : c_int ) -> c_float {
114
121
f64:: ldexp ( x as f64 , n as isize ) as c_float
115
122
}
116
123
124
+ #[ inline]
117
125
pub unsafe fn sinhf ( n : c_float ) -> c_float {
118
126
f64:: sinh ( n as f64 ) as c_float
119
127
}
120
128
129
+ #[ inline]
121
130
pub unsafe fn tanf ( n : c_float ) -> c_float {
122
131
f64:: tan ( n as f64 ) as c_float
123
132
}
124
133
134
+ #[ inline]
125
135
pub unsafe fn tanhf ( n : c_float ) -> c_float {
126
136
f64:: tanh ( n as f64 ) as c_float
127
137
}
@@ -272,8 +282,6 @@ impl f32 {
272
282
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
273
283
#[ inline]
274
284
pub fn floor ( self ) -> f32 {
275
- return floorf ( self ) ;
276
-
277
285
// On MSVC LLVM will lower many math intrinsics to a call to the
278
286
// corresponding function. On MSVC, however, many of these functions
279
287
// aren't actually available as symbols to call, but rather they are all
@@ -288,9 +296,9 @@ impl f32 {
288
296
// redirect to this comment, so `floorf` is just one case of a missing
289
297
// function on MSVC, but there are many others elsewhere.
290
298
#[ cfg( target_env = "msvc" ) ]
291
- fn floorf ( f : f32 ) -> f32 { ( f as f64 ) . floor ( ) as f32 }
299
+ return ( self as f64 ) . floor ( ) as f32 ;
292
300
#[ cfg( not( target_env = "msvc" ) ) ]
293
- fn floorf ( f : f32 ) -> f32 { unsafe { intrinsics:: floorf32 ( f ) } }
301
+ return unsafe { intrinsics:: floorf32 ( self ) } ;
294
302
}
295
303
296
304
/// Returns the smallest integer greater than or equal to a number.
@@ -305,13 +313,11 @@ impl f32 {
305
313
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
306
314
#[ inline]
307
315
pub fn ceil ( self ) -> f32 {
308
- return ceilf ( self ) ;
309
-
310
316
// see notes above in `floor`
311
317
#[ cfg( target_env = "msvc" ) ]
312
- fn ceilf ( f : f32 ) -> f32 { ( f as f64 ) . ceil ( ) as f32 }
318
+ return ( self as f64 ) . ceil ( ) as f32 ;
313
319
#[ cfg( not( target_env = "msvc" ) ) ]
314
- fn ceilf ( f : f32 ) -> f32 { unsafe { intrinsics:: ceilf32 ( f ) } }
320
+ return unsafe { intrinsics:: ceilf32 ( self ) } ;
315
321
}
316
322
317
323
/// Returns the nearest integer to a number. Round half-way cases away from
@@ -506,13 +512,11 @@ impl f32 {
506
512
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
507
513
#[ inline]
508
514
pub fn powf ( self , n : f32 ) -> f32 {
509
- return powf ( self , n) ;
510
-
511
515
// see notes above in `floor`
512
516
#[ cfg( target_env = "msvc" ) ]
513
- fn powf ( f : f32 , n : f32 ) -> f32 { ( f as f64 ) . powf ( n as f64 ) as f32 }
517
+ return ( self as f64 ) . powf ( n as f64 ) as f32 ;
514
518
#[ cfg( not( target_env = "msvc" ) ) ]
515
- fn powf ( f : f32 , n : f32 ) -> f32 { unsafe { intrinsics:: powf32 ( f , n) } }
519
+ return unsafe { intrinsics:: powf32 ( self , n) } ;
516
520
}
517
521
518
522
/// Takes the square root of a number.
@@ -557,13 +561,11 @@ impl f32 {
557
561
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
558
562
#[ inline]
559
563
pub fn exp ( self ) -> f32 {
560
- return expf ( self ) ;
561
-
562
564
// see notes above in `floor`
563
565
#[ cfg( target_env = "msvc" ) ]
564
- fn expf ( f : f32 ) -> f32 { ( f as f64 ) . exp ( ) as f32 }
566
+ return ( self as f64 ) . exp ( ) as f32 ;
565
567
#[ cfg( not( target_env = "msvc" ) ) ]
566
- fn expf ( f : f32 ) -> f32 { unsafe { intrinsics:: expf32 ( f ) } }
568
+ return unsafe { intrinsics:: expf32 ( self ) } ;
567
569
}
568
570
569
571
/// Returns `2^(self)`.
@@ -601,13 +603,11 @@ impl f32 {
601
603
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
602
604
#[ inline]
603
605
pub fn ln ( self ) -> f32 {
604
- return logf ( self ) ;
605
-
606
606
// see notes above in `floor`
607
607
#[ cfg( target_env = "msvc" ) ]
608
- fn logf ( f : f32 ) -> f32 { ( f as f64 ) . ln ( ) as f32 }
608
+ return ( self as f64 ) . ln ( ) as f32 ;
609
609
#[ cfg( not( target_env = "msvc" ) ) ]
610
- fn logf ( f : f32 ) -> f32 { unsafe { intrinsics:: logf32 ( f ) } }
610
+ return unsafe { intrinsics:: logf32 ( self ) } ;
611
611
}
612
612
613
613
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -664,13 +664,11 @@ impl f32 {
664
664
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
665
665
#[ inline]
666
666
pub fn log10 ( self ) -> f32 {
667
- return log10f ( self ) ;
668
-
669
667
// see notes above in `floor`
670
668
#[ cfg( target_env = "msvc" ) ]
671
- fn log10f ( f : f32 ) -> f32 { ( f as f64 ) . log10 ( ) as f32 }
669
+ return ( self as f64 ) . log10 ( ) as f32 ;
672
670
#[ cfg( not( target_env = "msvc" ) ) ]
673
- fn log10f ( f : f32 ) -> f32 { unsafe { intrinsics:: log10f32 ( f ) } }
671
+ return unsafe { intrinsics:: log10f32 ( self ) } ;
674
672
}
675
673
676
674
/// Converts radians to degrees.
@@ -884,13 +882,11 @@ impl f32 {
884
882
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
885
883
#[ inline]
886
884
pub fn sin ( self ) -> f32 {
887
- return sinf ( self ) ;
888
-
889
885
// see notes in `core::f32::Float::floor`
890
886
#[ cfg( target_env = "msvc" ) ]
891
- fn sinf ( f : f32 ) -> f32 { ( f as f64 ) . sin ( ) as f32 }
887
+ return ( self as f64 ) . sin ( ) as f32 ;
892
888
#[ cfg( not( target_env = "msvc" ) ) ]
893
- fn sinf ( f : f32 ) -> f32 { unsafe { intrinsics:: sinf32 ( f ) } }
889
+ return unsafe { intrinsics:: sinf32 ( self ) } ;
894
890
}
895
891
896
892
/// Computes the cosine of a number (in radians).
@@ -907,13 +903,11 @@ impl f32 {
907
903
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
908
904
#[ inline]
909
905
pub fn cos ( self ) -> f32 {
910
- return cosf ( self ) ;
911
-
912
906
// see notes in `core::f32::Float::floor`
913
907
#[ cfg( target_env = "msvc" ) ]
914
- fn cosf ( f : f32 ) -> f32 { ( f as f64 ) . cos ( ) as f32 }
908
+ return ( self as f64 ) . cos ( ) as f32 ;
915
909
#[ cfg( not( target_env = "msvc" ) ) ]
916
- fn cosf ( f : f32 ) -> f32 { unsafe { intrinsics:: cosf32 ( f ) } }
910
+ return unsafe { intrinsics:: cosf32 ( self ) } ;
917
911
}
918
912
919
913
/// Computes the tangent of a number (in radians).
0 commit comments