This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix sin, cos, tan in non-default rounding modes (bug 3976)
- From: Richard Henderson <rth at twiddle dot net>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: libc-alpha at sourceware dot org, Andreas Jaeger <aj at suse dot de>
- Date: Fri, 02 Mar 2012 12:31:07 -0800
- Subject: Re: Fix sin, cos, tan in non-default rounding modes (bug 3976)
- Authentication-results: mr.google.com; spf=pass (google.com: domain of rth7680@gmail.com designates 10.68.202.135 as permitted sender) smtp.mail=rth7680@gmail.com; dkim=pass header.i=rth7680@gmail.com
- References: <Pine.LNX.4.64.1203021737380.2188@digraph.polyomino.org.uk>
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~