aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-06-01 20:08:10 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-06-01 20:08:10 +0000
commit740890be239632e9274962447c270d2aa6b8647c (patch)
tree547647871ef27cc15c900ded7625b0be8e845538 /lib
parentea13a93166cbf1092e2471bd80f0fed2962aa12a (diff)
downloadsrc-740890be239632e9274962447c270d2aa6b8647c.tar.gz
src-740890be239632e9274962447c270d2aa6b8647c.zip
Partially revert r271349, which disabled the msun cexp test #4 on i386.
Ensure the expected result is stored first in a volatile variable with the desired type. This makes all the tests succeed. Slightly changed from the original pull request, but functionally the same. Obtained from: https://github.com/freebsd/freebsd/pull/401 Submitted by: Moritz Buhl <gh@moritzbuhl.de> PR: 191676 MFC after: 3 days
Notes
Notes: svn path=/head/; revision=348500
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/tests/cexp_test.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/msun/tests/cexp_test.c b/lib/msun/tests/cexp_test.c
index 5505849fab65..8e342f8e0070 100644
--- a/lib/msun/tests/cexp_test.c
+++ b/lib/msun/tests/cexp_test.c
@@ -59,13 +59,21 @@ __FBSDID("$FreeBSD$");
* XXX The volatile here is to avoid gcc's bogus constant folding and work
* around the lack of support for the FENV_ACCESS pragma.
*/
-#define test(func, z, result, exceptmask, excepts, checksign) do { \
+#define test_t(type, func, z, result, exceptmask, excepts, checksign) \
+do { \
volatile long double complex _d = z; \
+ volatile type complex _r = result; \
assert(feclearexcept(FE_ALL_EXCEPT) == 0); \
- assert(cfpequal_cs((func)(_d), (result), (checksign))); \
+ assert(cfpequal_cs((func)(_d), (_r), (checksign))); \
assert(((void)(func), fetestexcept(exceptmask) == (excepts))); \
} while (0)
+#define test(func, z, result, exceptmask, excepts, checksign) \
+ test_t(double, func, z, result, exceptmask, excepts, checksign)
+
+#define test_f(func, z, result, exceptmask, excepts, checksign) \
+ test_t(float, func, z, result, exceptmask, excepts, checksign)
+
/* Test within a given tolerance. */
#define test_tol(func, z, result, tol) do { \
volatile long double complex _d = z; \
@@ -76,7 +84,7 @@ __FBSDID("$FreeBSD$");
/* Test all the functions that compute cexp(x). */
#define testall(x, result, exceptmask, excepts, checksign) do { \
test(cexp, x, result, exceptmask, excepts, checksign); \
- test(cexpf, x, result, exceptmask, excepts, checksign); \
+ test_f(cexpf, x, result, exceptmask, excepts, checksign); \
} while (0)
/*
@@ -198,10 +206,10 @@ test_reals(void)
test(cexp, CMPLXL(finites[i], -0.0),
CMPLXL(exp(finites[i]), -0.0),
FE_INVALID | FE_DIVBYZERO, 0, 1);
- test(cexpf, CMPLXL(finites[i], 0.0),
+ test_f(cexpf, CMPLXL(finites[i], 0.0),
CMPLXL(expf(finites[i]), 0.0),
FE_INVALID | FE_DIVBYZERO, 0, 1);
- test(cexpf, CMPLXL(finites[i], -0.0),
+ test_f(cexpf, CMPLXL(finites[i], -0.0),
CMPLXL(expf(finites[i]), -0.0),
FE_INVALID | FE_DIVBYZERO, 0, 1);
}
@@ -220,10 +228,10 @@ test_imaginaries(void)
test(cexp, CMPLXL(-0.0, finites[i]),
CMPLXL(cos(finites[i]), sin(finites[i])),
ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
- test(cexpf, CMPLXL(0.0, finites[i]),
+ test_f(cexpf, CMPLXL(0.0, finites[i]),
CMPLXL(cosf(finites[i]), sinf(finites[i])),
ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
- test(cexpf, CMPLXL(-0.0, finites[i]),
+ test_f(cexpf, CMPLXL(-0.0, finites[i]),
CMPLXL(cosf(finites[i]), sinf(finites[i])),
ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
}
@@ -302,12 +310,8 @@ main(void)
test_inf();
printf("ok 3 - cexp inf\n");
-#if defined(__i386__)
- printf("not ok 4 - cexp reals # TODO: PR # 191676 fails assertion on i386\n");
-#else
test_reals();
printf("ok 4 - cexp reals\n");
-#endif
test_imaginaries();
printf("ok 5 - cexp imaginaries\n");