aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2018-04-10 05:48:31 +0000
committerTimo Teräs <timo.teras@iki.fi>2018-04-10 05:48:31 +0000
commitbda9cddfa33708bb55b5cc1ccf4c844ba6c9284a (patch)
treecbdfc7fa531b41e3d13380a1a10b7a23790d4cb0 /main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch
parentcbd6d5b76a903b24dc51fe354c0c8265f3f1a9a3 (diff)
downloadaports-bda9cddfa33708bb55b5cc1ccf4c844ba6c9284a.tar.bz2
aports-bda9cddfa33708bb55b5cc1ccf4c844ba6c9284a.tar.xz
main/musl: cherry-pick additional upstream fixes
Diffstat (limited to 'main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch')
-rw-r--r--main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch b/main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch
new file mode 100644
index 0000000000..d6326369dc
--- /dev/null
+++ b/main/musl/0005-fix-wrong-result-in-casin-and-many-related-complex-f.patch
@@ -0,0 +1,59 @@
+From ae2a01da2e388535da243b3d974aef74a3c06ae0 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Mon, 9 Apr 2018 12:33:17 -0400
+Subject: [PATCH] fix wrong result in casin and many related complex functions
+
+the factor of -i noted in the comment at the top of casin.c was
+omitted from the actual code, yielding a result rotated 90 degrees and
+propagating into errors in other functions defined in terms of casin.
+
+implement multiplication by -i as a rotation of the real and imaginary
+parts of the result, rather than by actual multiplication, since the
+latter cannot be optimized without knowledge that the operand is
+finite. here, the rotation is the actual intent, anyway.
+---
+ src/complex/casin.c | 3 ++-
+ src/complex/casinf.c | 3 ++-
+ src/complex/casinl.c | 3 ++-
+ 3 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/src/complex/casin.c b/src/complex/casin.c
+index dfdda988..01ed6184 100644
+--- a/src/complex/casin.c
++++ b/src/complex/casin.c
+@@ -12,5 +12,6 @@ double complex casin(double complex z)
+ x = creal(z);
+ y = cimag(z);
+ w = CMPLX(1.0 - (x - y)*(x + y), -2.0*x*y);
+- return clog(CMPLX(-y, x) + csqrt(w));
++ double complex r = clog(CMPLX(-y, x) + csqrt(w));
++ return CMPLX(cimag(r), -creal(r));
+ }
+diff --git a/src/complex/casinf.c b/src/complex/casinf.c
+index 93f0e335..4fcb76fc 100644
+--- a/src/complex/casinf.c
++++ b/src/complex/casinf.c
+@@ -10,5 +10,6 @@ float complex casinf(float complex z)
+ x = crealf(z);
+ y = cimagf(z);
+ w = CMPLXF(1.0 - (x - y)*(x + y), -2.0*x*y);
+- return clogf(CMPLXF(-y, x) + csqrtf(w));
++ float complex r = clogf(CMPLXF(-y, x) + csqrtf(w));
++ return CMPLXF(cimagf(r), -crealf(r));
+ }
+diff --git a/src/complex/casinl.c b/src/complex/casinl.c
+index 0916c60f..3b7ceba7 100644
+--- a/src/complex/casinl.c
++++ b/src/complex/casinl.c
+@@ -15,6 +15,7 @@ long double complex casinl(long double complex z)
+ x = creall(z);
+ y = cimagl(z);
+ w = CMPLXL(1.0 - (x - y)*(x + y), -2.0*x*y);
+- return clogl(CMPLXL(-y, x) + csqrtl(w));
++ long double complex r = clogl(CMPLXL(-y, x) + csqrtl(w));
++ return CMPLXL(cimagl(r), -creall(r));
+ }
+ #endif
+--
+2.17.0
+