@@ -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,12 +182,28 @@ 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.
@@ -324,3 +339,37 @@ impl MpOp for crate::op::lgammaf_r::Routine {
324339 ( ret, sign as i32 )
325340 }
326341}
342+
343+ /* Not all `f16` and `f128` functions exist yet so we can't easily use the macros. */
344+
345+ #[ cfg( f16_enabled) ]
346+ impl MpOp for crate :: op:: copysignf16:: Routine {
347+ type MpTy = ( MpFloat , MpFloat ) ;
348+
349+ fn new_mp ( ) -> Self :: MpTy {
350+ ( new_mpfloat :: < f16 > ( ) , new_mpfloat :: < f16 > ( ) )
351+ }
352+
353+ fn run ( this : & mut Self :: MpTy , input : Self :: RustArgs ) -> Self :: RustRet {
354+ this. 0 . assign ( input. 0 ) ;
355+ this. 1 . assign ( input. 1 ) ;
356+ this. 0 . copysign_mut ( & this. 1 ) ;
357+ prep_retval :: < Self :: RustRet > ( & mut this. 0 , Ordering :: Equal )
358+ }
359+ }
360+
361+ #[ cfg( f128_enabled) ]
362+ impl MpOp for crate :: op:: copysignf128:: Routine {
363+ type MpTy = ( MpFloat , MpFloat ) ;
364+
365+ fn new_mp ( ) -> Self :: MpTy {
366+ ( new_mpfloat :: < f128 > ( ) , new_mpfloat :: < f128 > ( ) )
367+ }
368+
369+ fn run ( this : & mut Self :: MpTy , input : Self :: RustArgs ) -> Self :: RustRet {
370+ this. 0 . assign ( input. 0 ) ;
371+ this. 1 . assign ( input. 1 ) ;
372+ this. 0 . copysign_mut ( & this. 1 ) ;
373+ prep_retval :: < Self :: RustRet > ( & mut this. 0 , Ordering :: Equal )
374+ }
375+ }
0 commit comments