From d47907f725947fdb40ad7f39c505cb3cfcc4fd3e Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 11 Jun 2018 00:40:08 -0500 Subject: system/musl: more complex fixes --- system/musl/APKBUILD | 8 +++-- system/musl/complex-math2.patch | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 system/musl/complex-math2.patch (limited to 'system/musl') diff --git a/system/musl/APKBUILD b/system/musl/APKBUILD index 5b80c8dda..47e1b4e0a 100644 --- a/system/musl/APKBUILD +++ b/system/musl/APKBUILD @@ -1,9 +1,9 @@ # Contributor: William Pitcock -# Maintainer: Timo Teräs +# Maintainer: A. Wilcox pkgname=musl pkgver=1.1.19 -pkgrel=4 -pkgdesc="the musl c library (libc) implementation" +pkgrel=5 +pkgdesc="System library (libc) implementation" url="http://www.musl-libc.org/" arch="all" options="!check" @@ -28,6 +28,7 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch complex-math.patch + complex-math2.patch handle-aux-at_base.patch ldconfig @@ -159,6 +160,7 @@ d0d0817a4e1d57b74cb442a3bf8d8efe39a23a387275b75cba1b2fa354d8a7dc2fd843b5b67584aa 6f5f9b5fb5eba638b0d98c68c280dbcc2bdae58d94d9f6966f5de55f6dd5d7f3cdddd9ca758e8861e30841b80ba616a945fb2b885a31481707d578293b187ff0 0007-abort-raise-SIGABRT-again-if-signal-is-ignored.patch 2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch 8909dc260968770ace8f3ffdc04c6c7d20933ff115b4fa3e512fb7460860a8216c73ca7a7ad54f59cb5988ef011f02bf18aa13cc2287cc64ffdb8db84ef69d47 complex-math.patch +c34ae0c8c2b05d82bc6bd341ceb29041f6e1a1d2c7b2f4f289ab620288bfb1e1ddabc4cb2fc85220c1fbe735874c38a9b00af636644584c7cd1e895d54564a22 complex-math2.patch 6a7ff16d95b5d1be77e0a0fbb245491817db192176496a57b22ab037637d97a185ea0b0d19da687da66c2a2f5578e4343d230f399d49fe377d8f008410974238 handle-aux-at_base.patch 8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig 062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c diff --git a/system/musl/complex-math2.patch b/system/musl/complex-math2.patch new file mode 100644 index 000000000..49f5c3acd --- /dev/null +++ b/system/musl/complex-math2.patch @@ -0,0 +1,79 @@ +From 10e4bd3780050e75b72aac5d85c31816419bb17d Mon Sep 17 00:00:00 2001 +From: Rich Felker +Date: Wed, 11 Apr 2018 15:05:22 -0400 +Subject: [PATCH 1/2] fix incorrect results for catan with some inputs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +the catan implementation from OpenBSD includes a FIXME-annotated +"overflow" branch that produces a meaningless and incorrect +large-magnitude result. it was reachable via three paths, +corresponding to gotos removed by this commit, in order: + +1. pure imaginary argument with imaginary component greater than 1 in + magnitude. this case does not seem at all exceptional and is + handled (at least with the quality currently expected from our + complex math functions) by the existing non-exceptional code path. + +2. arguments on the unit circle, including the pure-real argument 1.0. + these are not exceptional except for ±i, which should produce + results with infinite imaginary component and which lead to + computation of atan2(±0,0) in the existing non-exceptional code + path. such calls to atan2() however are well-defined by POSIX. + +3. the specific argument +i. this route should be unreachable due to + the above (2), but subtle rounding effects might have made it + possible in rare cases. continuing on the non-exceptional code path + in this case would lead to computing the (real) log of an infinite + argument, then producing a NAN when multiplying it by I. + +for now, remove the exceptional code paths entirely. replace the +multiplication by I with construction of a complex number using the +CMPLX macro so that the NAN issue (3) prevented cannot arise. + +with these changes, catan should give reasonably correct results for +real arguments, and should no longer give completely-wrong results for +pure-imaginary arguments outside the interval (-i,+i). +--- + src/complex/catan.c | 14 +------------- + 1 file changed, 1 insertion(+), 13 deletions(-) + +diff --git a/src/complex/catan.c b/src/complex/catan.c +index 39ce6cf2..7dc2afeb 100644 +--- a/src/complex/catan.c ++++ b/src/complex/catan.c +@@ -91,29 +91,17 @@ double complex catan(double complex z) + x = creal(z); + y = cimag(z); + +- if (x == 0.0 && y > 1.0) +- goto ovrf; +- + x2 = x * x; + a = 1.0 - x2 - (y * y); +- if (a == 0.0) +- goto ovrf; + + t = 0.5 * atan2(2.0 * x, a); + w = _redupi(t); + + t = y - 1.0; + a = x2 + (t * t); +- if (a == 0.0) +- goto ovrf; + + t = y + 1.0; + a = (x2 + t * t)/a; +- w = w + (0.25 * log(a)) * I; +- return w; +- +-ovrf: +- // FIXME +- w = MAXNUM + MAXNUM * I; ++ w = CMPLX(w, 0.25 * log(a)); + return w; + } +-- +2.15.0 + -- cgit v1.2.3-70-g09d2