Fix sin, cos, tan in non-default rounding modes (bug 3976)

Richard Henderson rth@twiddle.net
Fri Mar 2 20:31:00 GMT 2012


On 03/02/2012 09:39 AM, Joseph S. Myers wrote:
> +  fenv_t env;
> +  double retval;
> +
>    int __branred(double, double *, double *);
>    int __mpranred(double, mp_no *, int);
>  
> +  libc_feholdexcept_setround (&env, FE_TONEAREST);

Might it be easier to set up a macro in an internal header,

#define WRAP_ROUND_TO_NEAREST \
  fenv_t env __attribute__((cleanup(libc_feupdateenv))); \
  libc_feholdexcept_setround (&env, FE_TONEAREST)

and letting the compiler insert the cleanup?

If the resulting code is significantly worse, fine, but
it seems these current fixes make it easy to miss a return.


r~



More information about the Libc-alpha mailing list