From owner-freebsd-numerics@freebsd.org Tue Mar 5 04:48:32 2019 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C7AC1513542 for ; Tue, 5 Mar 2019 04:48:32 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id DC5CC76F6B for ; Tue, 5 Mar 2019 04:48:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 7C8EB108CBD4; Tue, 5 Mar 2019 15:48:12 +1100 (AEDT) Date: Tue, 5 Mar 2019 15:48:11 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl cc: freebsd-numerics@freebsd.org Subject: Re: Update ENTERI() macro In-Reply-To: <20190304212159.GA12587@troutmask.apl.washington.edu> Message-ID: <20190305153243.Y1349@besplex.bde.org> References: <20190226191825.GA68479@troutmask.apl.washington.edu> <20190227145002.P907@besplex.bde.org> <20190227074811.GA75972@troutmask.apl.washington.edu> <20190227201214.V1823@besplex.bde.org> <20190227161906.GA77785@troutmask.apl.washington.edu> <20190228060920.R4413@besplex.bde.org> <20190304212159.GA12587@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=UJetJGXy c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=JQ0e4kNsG--EZ3fqZAAA:9 a=CjuIK1q_8ugA:10 X-Rspamd-Queue-Id: DC5CC76F6B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of brde@optusnet.com.au designates 211.29.132.249 as permitted sender) smtp.mailfrom=brde@optusnet.com.au X-Spamd-Result: default: False [-6.09 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; FREEMAIL_FROM(0.00)[optusnet.com.au]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[optusnet.com.au]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[extmail.optusnet.com.au]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.74)[-0.738,0]; IP_SCORE(-3.04)[ip: (-7.87), ipnet: 211.28.0.0/14(-4.05), asn: 4804(-3.23), country: AU(-0.04)]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_IN_DNSWL_LOW(-0.10)[249.132.29.211.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2019 04:48:32 -0000 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. Bruce