Update ENTERI() macro
Steve Kargl
sgk at troutmask.apl.washington.edu
Wed Mar 6 05:52:11 UTC 2019
On Tue, Mar 05, 2019 at 03:48:11PM +1100, Bruce Evans wrote:
> On Mon, 4 Mar 2019, Steve Kargl wrote:
>
> > On Thu, Feb 28, 2019 at 07:15:14AM +1100, Bruce Evans wrote:
> >> ...
> >> I said to use your method of __typeof(). I tested this:
> >>
> >> XX --- /tmp/math_private.h Sun Nov 27 17:58:57 2005
> >> XX +++ ./math_private.h Thu Feb 28 06:17:26 2019
> >> XX @@ -474,21 +474,22 @@
> >> XX /* Support switching the mode to FP_PE if necessary. */
> >> XX #if defined(__i386__) && !defined(NO_FPSETPREC)
> >> XX -#define ENTERI() ENTERIT(long double)
> >> XX -#define ENTERIT(returntype) \
> >> XX - returntype __retval; \
> >> XX +#define ENTERI() \
> >> XX fp_prec_t __oprec; \
> >> XX \
> >> XX if ((__oprec = fpgetprec()) != FP_PE) \
> >> XX fpsetprec(FP_PE)
> >> XX -#define RETURNI(x) do { \
> >> XX - __retval = (x); \
> >> XX - if (__oprec != FP_PE) \
> >> XX - fpsetprec(__oprec); \
> >> XX +#define LEAVEI() \
> >> XX + if ((__oprec = fpgetprec()) != FP_PE) \
> >> XX + fpsetprec(FP_PE)
> >
> > Am I reading this diff wrong? Should LEAVEI() be
> >
> > #define LEAVEI() \
> > if (__oprec != FP_PE) \
> > fpsetprec(__oprec)
> >
> > That is, we want to reset the precision to what ENTERI
> > grabbed in its conditinal expression.
>
> Oops. I wrote it wrong by copying the wrong clause.
>
> The broken version even passed quick runtime tests. This is because
> the tests know that most long double functions are missing ENTERI(),
> so they set the precision to FP_PE before the call. So both ENTERI()
> and LEAVEI() find (__oprec = fpgetprec() equal to FP_PE and do nothing.
>
My math_private.h has a few additions, which meant I applied
your diff manually. As I was reading it, I came across the
issue.
I think I have the s_cexpl.c file fixed to use LDBL_EXTRACT_WORDS
instead of the new macro I introduced. I however cannot figure
out what David Das did to arrive at k_exp.c, so I cannot write
a similar k_cexpl.c. Yes, I added the 'c' in the name to avoid
confusion in ld80/. In particular, I have no idea how he found
his scaling value 'k'. Any insights?
--
Steve
More information about the freebsd-numerics
mailing list