From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14777 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Patch for cacosh Date: Tue, 1 Oct 2019 19:28:13 -0400 Message-ID: <20191001232813.GG16318@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="200846"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14793-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 02 01:28:29 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iFRZE-000q9z-S0 for gllmg-musl@m.gmane.org; Wed, 02 Oct 2019 01:28:28 +0200 Original-Received: (qmail 9828 invoked by uid 550); 1 Oct 2019 23:28:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9807 invoked from network); 1 Oct 2019 23:28:25 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14777 Archived-At: On Tue, Oct 01, 2019 at 09:57:17PM +0000, Michael Morrell wrote: > Running the gcc validation suite, I noticed that > gfortran.dg/complex_intrinsic_5.f90 was failing when using MUSL. > > I tracked it down to the cacosh routines not getting the correct > result when the imaginary part of the argument was negative. > > Attached is a patch to fix this. Thanks! > diff --git a/src/complex/cacosh.c b/src/complex/cacosh.c > index 8c68cb01..0b598052 100644 > --- a/src/complex/cacosh.c > +++ b/src/complex/cacosh.c > @@ -4,6 +4,9 @@ > > double complex cacosh(double complex z) > { > + _Bool zineg = cimag(z) < 0; > + I think this fails to give the desired result for negative zero. Should probably be signbit(cimag(z)) or similar. If there's a way to adjust the input to cacos to avoid having to patch up after it returns based on a flag saved before the call, that would make it more efficient I think (no need to spill/reload), but it's not a big deal if not. Also, as a style matter, musl codebase generally doesn't use _Bool; rather just int for flags/boolean values. Rich