From owner-freebsd-numerics@freebsd.org Mon Mar 4 21:31:42 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 57EF71523E26 for ; Mon, 4 Mar 2019 21:31:42 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id C4DD38953C for ; Mon, 4 Mar 2019 21:31:40 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x24LM54d012616 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 4 Mar 2019 13:22:06 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x24LM5jp012603; Mon, 4 Mar 2019 13:22:05 -0800 (PST) (envelope-from sgk) Date: Mon, 4 Mar 2019 13:21:59 -0800 From: Steve Kargl To: Bruce Evans Cc: freebsd-numerics@freebsd.org Subject: Re: Update ENTERI() macro Message-ID: <20190304212159.GA12587@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190228060920.R4413@besplex.bde.org> User-Agent: Mutt/1.11.2 (2019-01-07) X-Rspamd-Queue-Id: C4DD38953C X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [1.33 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[sgk@troutmask.apl.washington.edu]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(0.66)[0.665,0]; NEURAL_HAM_LONG(-0.16)[-0.157,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[washington.edu]; AUTH_NA(1.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[21.76.95.128.list.dnswl.org : 127.0.11.2]; MX_GOOD(-0.01)[troutmask.apl.washington.edu]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_MEDIUM(0.08)[0.083,0]; R_SPF_NA(0.00)[]; FREEMAIL_TO(0.00)[optusnet.com.au]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:73, ipnet:128.95.0.0/16, country:US]; MID_RHS_MATCH_FROM(0.00)[]; IP_SCORE(0.05)[ip: (0.10), ipnet: 128.95.0.0/16(0.15), asn: 73(0.06), country: US(-0.07)] 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: Mon, 04 Mar 2019 21:31:42 -0000 On Thu, Feb 28, 2019 at 07:15:14AM +1100, Bruce Evans wrote: > On Wed, 27 Feb 2019, Steve Kargl wrote: > > > On Wed, Feb 27, 2019 at 09:15:52PM +1100, Bruce Evans wrote: > >> > >> ENTERI() hard-codes the long double for simplicity. Remember, it is only > >> needed for long double precision on i386. But I forgot about long double > >> complex types, and didn't dream about indirect long double types in sincosl(). > > > > That simplicity does not work for long double complex. We will > > > > need either ENTERIC as in > > > > #define ENTERIC() ENTERIT(long double complex) > > > > or a direct use of ENTERIT as you have done s_clogl.c > > I wrote ENTERIT() to work around this problem. > > >>> I'm fine with making ENTERI() only toggle precision, and adding > >>> a LEAVEI() to reset precision. RETURNI(r) would then be > >>> > >>> #define RETURNI(r) \ > >>> do { \ > >>> LEAVEI(); \ > >>> return (r); \ > >>> } while (0) > >> > >> No, may be an expression, so it must be evaluated before LEAVEI(). This > >> is the reason for existence of the variable to hold the result. > > > > So, we'll need RETURNI for long double and one for long double complex. > > Or, we give RETURNI a second parameter, which is the input parameter of > > the function > > 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. -- Steve 20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4 20161221 https://www.youtube.com/watch?v=IbCHE-hONow