From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14786 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Morrell Newsgroups: gmane.linux.lib.musl.general Subject: RE: Patch for cacosh Date: Wed, 2 Oct 2019 16:45:14 +0000 Message-ID: References: <20191001232813.GG16318@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_002_d90ed963baad4b4fa5475b7b7643a0c5tachyumcom_" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="209761"; mail-complaints-to="usenet@blaine.gmane.org" To: "musl@lists.openwall.com" Original-X-From: musl-return-14802-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 02 18:45:31 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 1iFhkp-000sSo-64 for gllmg-musl@m.gmane.org; Wed, 02 Oct 2019 18:45:31 +0200 Original-Received: (qmail 5546 invoked by uid 550); 2 Oct 2019 16:45:28 -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 5528 invoked from network); 2 Oct 2019 16:45:27 -0000 Thread-Topic: [musl] Patch for cacosh Thread-Index: AdV4ouOUFagnRjq3Tua6i6AtdIhmAgAR62OAABVnGgA= In-Reply-To: <20191001232813.GG16318@brightrain.aerifal.cx> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes x-originating-ip: [10.7.100.157] Xref: news.gmane.org gmane.linux.lib.musl.general:14786 Archived-At: --_002_d90ed963baad4b4fa5475b7b7643a0c5tachyumcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Here's a revised version that used "int" instead of "_Bool" and signbit(). = You were correct that -0 failed. I'm not sure how to do this by adjusting the input to cacos, so I left that= alone. Thanks for considering taking this patch. Most of the rest of the failure= s in the Fortran portion of the gcc validation suite are due to lack of qua= d math support which I know is something you want to tackle, but is still a= ways off. Michael -----Original Message----- From: Rich Felker On Behalf Of Rich Felker Sent: Tuesday, October 1, 2019 4:28 PM To: musl@lists.openwall.com Subject: Re: [musl] Patch for cacosh 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. >=20 > I tracked it down to the cacosh routines not getting the correct=20 > result when the imaginary part of the argument was negative. >=20 > Attached is a patch to fix this. Thanks! > diff --git a/src/complex/cacosh.c b/src/complex/cacosh.c index=20 > 8c68cb01..0b598052 100644 > --- a/src/complex/cacosh.c > +++ b/src/complex/cacosh.c > @@ -4,6 +4,9 @@ > =20 > double complex cacosh(double complex z) { > + _Bool zineg =3D 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 a= fter it returns based on a flag saved before the call, that would make it m= ore 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 --_002_d90ed963baad4b4fa5475b7b7643a0c5tachyumcom_ Content-Type: application/octet-stream; name="cacosh.patch" Content-Description: cacosh.patch Content-Disposition: attachment; filename="cacosh.patch"; size=1281; creation-date="Wed, 02 Oct 2019 16:44:54 GMT"; modification-date="Fri, 26 Apr 2019 21:57:34 GMT" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9jb21wbGV4L2NhY29zaC5jIGIvc3JjL2NvbXBsZXgvY2Fjb3NoLmMK aW5kZXggOGU0MmYxYWUuLjc2MTI3Zjc1IDEwMDY0NAotLS0gYS9zcmMvY29tcGxleC9jYWNvc2gu YworKysgYi9zcmMvY29tcGxleC9jYWNvc2guYwpAQCAtNCw2ICs0LDkgQ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