Skip to content

Commit

Permalink
MFC r348500:
Browse files Browse the repository at this point in the history
Partially revert r271349, which disabled the msun cexp test freebsd#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:	freebsd#401
Submitted by:	Moritz Buhl <gh@moritzbuhl.de>
PR:		191676


git-svn-id: https://svn.freebsd.org/base/stable/12@348784 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
  • Loading branch information
dim committed Jun 7, 2019
1 parent 9b71177 commit ef4b835
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/msun/tests/cexp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand All @@ -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)

/*
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit ef4b835

Please sign in to comment.