@@ -137,6 +137,7 @@ libm_macros::for_each_function! {
137
137
fmod, fmodf, frexp, frexpf, ilogb, ilogbf, jn, jnf, ldexp, ldexpf,
138
138
lgamma_r, lgammaf_r, modf, modff, nextafter, nextafterf, pow, powf,
139
139
remquo, remquof, scalbn, scalbnf, sincos, sincosf, yn, ynf,
140
+ copysignf16, copysignf128, fabsf16, fabsf128,
140
141
] ,
141
142
fn_extra: match MACRO_FN_NAME {
142
143
// Remap function names that are different between mpfr and libm
@@ -157,10 +158,8 @@ libm_macros::for_each_function! {
157
158
/// Implement unary functions that don't have a `_round` version
158
159
macro_rules! impl_no_round {
159
160
// Unary matcher
160
- ( $( $fn_name: ident, $rug_name: ident; ) * ) => {
161
+ ( $( $fn_name: ident => $rug_name: ident; ) * ) => {
161
162
paste:: paste! {
162
- // Implement for both f32 and f64
163
- $( impl_no_round!{ @inner_unary [ < $fn_name f >] , $rug_name } ) *
164
163
$( impl_no_round!{ @inner_unary $fn_name, $rug_name } ) *
165
164
}
166
165
} ;
@@ -183,33 +182,34 @@ macro_rules! impl_no_round {
183
182
}
184
183
185
184
impl_no_round ! {
186
- fabs, abs_mut;
187
- ceil, ceil_mut;
188
- floor, floor_mut;
189
- rint, round_even_mut; // FIXME: respect rounding mode
190
- round, round_mut;
191
- trunc, trunc_mut;
185
+ ceil => ceil_mut;
186
+ ceilf => ceil_mut;
187
+ fabs => abs_mut;
188
+ fabsf => abs_mut;
189
+ floor => floor_mut;
190
+ floorf => floor_mut;
191
+ rint => round_even_mut; // FIXME: respect rounding mode
192
+ rintf => round_even_mut; // FIXME: respect rounding mode
193
+ round => round_mut;
194
+ roundf => round_mut;
195
+ trunc => trunc_mut;
196
+ truncf => trunc_mut;
197
+ }
198
+
199
+ #[ cfg( f16_enabled) ]
200
+ impl_no_round ! {
201
+ fabsf16 => abs_mut;
202
+ }
203
+
204
+ #[ cfg( f128_enabled) ]
205
+ impl_no_round ! {
206
+ fabsf128 => abs_mut;
192
207
}
193
208
194
209
/// Some functions are difficult to do in a generic way. Implement them here.
195
210
macro_rules! impl_op_for_ty {
196
211
( $fty: ty, $suffix: literal) => {
197
212
paste:: paste! {
198
- impl MpOp for crate :: op:: [ <copysign $suffix>] :: Routine {
199
- type MpTy = ( MpFloat , MpFloat ) ;
200
-
201
- fn new_mp( ) -> Self :: MpTy {
202
- ( new_mpfloat:: <Self :: FTy >( ) , new_mpfloat:: <Self :: FTy >( ) )
203
- }
204
-
205
- fn run( this: & mut Self :: MpTy , input: Self :: RustArgs ) -> Self :: RustRet {
206
- this. 0 . assign( input. 0 ) ;
207
- this. 1 . assign( input. 1 ) ;
208
- this. 0 . copysign_mut( & this. 1 ) ;
209
- prep_retval:: <Self :: RustRet >( & mut this. 0 , Ordering :: Equal )
210
- }
211
- }
212
-
213
213
impl MpOp for crate :: op:: [ <pow $suffix>] :: Routine {
214
214
type MpTy = ( MpFloat , MpFloat ) ;
215
215
@@ -291,9 +291,38 @@ macro_rules! impl_op_for_ty {
291
291
} ;
292
292
}
293
293
294
+ /// Version of `impl_op_for_ty` with only functions that have `f16` and `f128` implementations.
295
+ macro_rules! impl_op_for_ty_all {
296
+ ( $fty: ty, $suffix: literal) => {
297
+ paste:: paste! {
298
+ impl MpOp for crate :: op:: [ <copysign $suffix>] :: Routine {
299
+ type MpTy = ( MpFloat , MpFloat ) ;
300
+
301
+ fn new_mp( ) -> Self :: MpTy {
302
+ ( new_mpfloat:: <Self :: FTy >( ) , new_mpfloat:: <Self :: FTy >( ) )
303
+ }
304
+
305
+ fn run( this: & mut Self :: MpTy , input: Self :: RustArgs ) -> Self :: RustRet {
306
+ this. 0 . assign( input. 0 ) ;
307
+ this. 1 . assign( input. 1 ) ;
308
+ this. 0 . copysign_mut( & this. 1 ) ;
309
+ prep_retval:: <Self :: RustRet >( & mut this. 0 , Ordering :: Equal )
310
+ }
311
+ }
312
+ }
313
+ } ;
314
+ }
315
+
294
316
impl_op_for_ty ! ( f32 , "f" ) ;
295
317
impl_op_for_ty ! ( f64 , "" ) ;
296
318
319
+ #[ cfg( f16_enabled) ]
320
+ impl_op_for_ty_all ! ( f16, "f16" ) ;
321
+ impl_op_for_ty_all ! ( f32 , "f" ) ;
322
+ impl_op_for_ty_all ! ( f64 , "" ) ;
323
+ #[ cfg( f128_enabled) ]
324
+ impl_op_for_ty_all ! ( f128, "f128" ) ;
325
+
297
326
// `lgamma_r` is not a simple suffix so we can't use the above macro.
298
327
impl MpOp for crate :: op:: lgamma_r:: Routine {
299
328
type MpTy = MpFloat ;
0 commit comments