@@ -137,6 +137,7 @@ libm_macros::for_each_function! {
137137 fmod, fmodf, frexp, frexpf, ilogb, ilogbf, jn, jnf, ldexp, ldexpf,
138138 lgamma_r, lgammaf_r, modf, modff, nextafter, nextafterf, pow, powf,
139139 remquo, remquof, scalbn, scalbnf, sincos, sincosf, yn, ynf,
140+ copysignf16, copysignf128, fabsf16, fabsf128,
140141 ] ,
141142 fn_extra: match MACRO_FN_NAME {
142143 // Remap function names that are different between mpfr and libm
@@ -157,10 +158,8 @@ libm_macros::for_each_function! {
157158/// Implement unary functions that don't have a `_round` version
158159macro_rules! impl_no_round {
159160 // Unary matcher
160- ( $( $fn_name: ident, $rug_name: ident; ) * ) => {
161+ ( $( $fn_name: ident => $rug_name: ident; ) * ) => {
161162 paste:: paste! {
162- // Implement for both f32 and f64
163- $( impl_no_round!{ @inner_unary [ < $fn_name f >] , $rug_name } ) *
164163 $( impl_no_round!{ @inner_unary $fn_name, $rug_name } ) *
165164 }
166165 } ;
@@ -183,33 +182,34 @@ macro_rules! impl_no_round {
183182}
184183
185184impl_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;
192207}
193208
194209/// Some functions are difficult to do in a generic way. Implement them here.
195210macro_rules! impl_op_for_ty {
196211 ( $fty: ty, $suffix: literal) => {
197212 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-
213213 impl MpOp for crate :: op:: [ <pow $suffix>] :: Routine {
214214 type MpTy = ( MpFloat , MpFloat ) ;
215215
@@ -291,9 +291,38 @@ macro_rules! impl_op_for_ty {
291291 } ;
292292}
293293
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+
294316impl_op_for_ty ! ( f32 , "f" ) ;
295317impl_op_for_ty ! ( f64 , "" ) ;
296318
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+
297326// `lgamma_r` is not a simple suffix so we can't use the above macro.
298327impl MpOp for crate :: op:: lgamma_r:: Routine {
299328 type MpTy = MpFloat ;
0 commit comments