From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14776 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Morrell Newsgroups: gmane.linux.lib.musl.general Subject: Patch for cacosh Date: Tue, 1 Oct 2019 21:57:17 +0000 Message-ID: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_004_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="101207"; mail-complaints-to="usenet@blaine.gmane.org" To: "musl@lists.openwall.com" Original-X-From: musl-return-14792-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 01 23:57:35 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 1iFQ9G-000QAq-Ba for gllmg-musl@m.gmane.org; Tue, 01 Oct 2019 23:57:34 +0200 Original-Received: (qmail 26069 invoked by uid 550); 1 Oct 2019 21:57:31 -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 26036 invoked from network); 1 Oct 2019 21:57:30 -0000 Thread-Topic: Patch for cacosh Thread-Index: AdV4ouOUFagnRjq3Tua6i6AtdIhmAg== 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:14776 Archived-At: --_004_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_ Content-Type: multipart/alternative; boundary="_000_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_" --_000_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Running the gcc validation suite, I noticed that gfortran.dg/complex_intrin= sic_5.f90 was failing when using MUSL. I tracked it down to the cacosh routines not getting the correct result whe= n the imaginary part of the argument was negative. Attached is a patch to fix this. Michael --_000_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Running the gcc validation suite, I noticed that gfo= rtran.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.

 

  Michael

--_000_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_-- --_004_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_ Content-Type: application/octet-stream; name="cacosh.patch" Content-Description: cacosh.patch Content-Disposition: attachment; filename="cacosh.patch"; size=1279; creation-date="Tue, 01 Oct 2019 21:52:33 GMT"; modification-date="Fri, 26 Apr 2019 21:57:34 GMT" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9jb21wbGV4L2NhY29zaC5jIGIvc3JjL2NvbXBsZXgvY2Fjb3NoLmMK aW5kZXggOGM2OGNiMDEuLjBiNTk4MDUyIDEwMDY0NAotLS0gYS9zcmMvY29tcGxleC9jYWNvc2gu YworKysgYi9zcmMvY29tcGxleC9jYWNvc2guYwpAQCAtNCw2ICs0LDkgQEAKIAogZG91YmxlIGNv bXBsZXggY2Fjb3NoKGRvdWJsZSBjb21wbGV4IHopCiB7CisgICAgICAgIF9Cb29sIHppbmVnID0g Y2ltYWcoeikgPCAwOworCiAJeiA9IGNhY29zKHopOwotCXJldHVybiBDTVBMWCgtY2ltYWcoeiks IGNyZWFsKHopKTsKKwlpZiAoemluZWcpIHJldHVybiBDTVBMWChjaW1hZyh6KSwgLWNyZWFsKHop KTsKKwllbHNlICAgICAgIHJldHVybiBDTVBMWCgtY2ltYWcoeiksIGNyZWFsKHopKTsKIH0KZGlm ZiAtLWdpdCBhL3NyYy9jb21wbGV4L2NhY29zaGYuYyBiL3NyYy9jb21wbGV4L2NhY29zaGY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004_df809c4a40da4b46a53c4e78c1b20c75tachyumcom_-- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14781 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Patch for cacosh Date: Wed, 2 Oct 2019 13:49:03 +0200 Message-ID: <20191002114902.GC7832@port70.net> 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="257907"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14797-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 02 13:49:18 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 1iFd89-0014wV-QP for gllmg-musl@m.gmane.org; Wed, 02 Oct 2019 13:49:17 +0200 Original-Received: (qmail 22137 invoked by uid 550); 2 Oct 2019 11:49:15 -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 22114 invoked from network); 2 Oct 2019 11:49:14 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:14781 Archived-At: * Michael Morrell [2019-10-01 21:57:17 +0000]: > 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. yeah the complex functions are not expected to be correct: i made no attempt to get all principal values right nor to deal with fp format special cases (rounding, overflow,..) i suspect that even with the sign check all sorts of special cases are wrong (input with large real or imag part), but if it helps somewhere then i think it's ok to add the patch (it should just be clear that the implementation is not expected to be correct, fixing up complex would be a huge amount of work) > > Attached is a patch to fix this. > > Michael 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 YworKysgYi9zcmMvY29tcGxleC9jYWNvc2guYwpAQCAtNCw2ICs0LDkgQEAKIAogZG91YmxlIGNv bXBsZXggY2Fjb3NoKGRvdWJsZSBjb21wbGV4IHopCiB7CisJaW50IHppbmVnID0gc2lnbmJpdChj aW1hZyh6KSk7CisKIAl6ID0gY2Fjb3Moeik7Ci0JcmV0dXJuIENNUExYKC1jaW1hZyh6KSwgY3Jl YWwoeikpOworCWlmICh6aW5lZykgcmV0dXJuIENNUExYKGNpbWFnKHopLCAtY3JlYWwoeikpOwor CWVsc2UgICAgICAgcmV0dXJuIENNUExYKC1jaW1hZyh6KSwgY3JlYWwoeikpOwogfQpkaWZmIC0t Z2l0IGEvc3JjL2NvbXBsZXgvY2Fjb3NoZi5jIGIvc3JjL2NvbXBsZXgvY2Fjb3NoZi5jCmluZGV4 IGQ3ZTZiNTQ1Li44YmQ4MDU4MSAxMDA2NDQKLS0tIGEvc3JjL2NvbXBsZXgvY2Fjb3NoZi5jCisr KyBiL3NyYy9jb21wbGV4L2NhY29zaGYuYwpAQCAtMiw2ICsyLDkgQEAKIAogZmxvYXQgY29tcGxl eCBjYWNvc2hmKGZsb2F0IGNvbXBsZXggeikKIHsKKwlpbnQgemluZWcgPSBzaWduYml0KGNpbWFn Zih6KSk7CisKIAl6ID0gY2Fjb3NmKHopOwotCXJldHVybiBDTVBMWEYoLWNpbWFnZih6KSwgY3Jl YWxmKHopKTsKKwlpZiAoemluZWcpIHJldHVybiBDTVBMWEYoY2ltYWdmKHopLCAtY3JlYWxmKHop KTsKKwllbHNlICAgICAgIHJldHVybiBDTVBMW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