Hi Daniel, On 2/4/21 8:17 AM, Daniel Lehman wrote:
-static void test_feenv(void) +static DISABLE_OPT void test_feenv(void) { + static const struct { + double num, denom; + int flag; + } tests[] = { + { 1.0, 10.0, FE_INEXACT }, + { DBL_MIN, DBL_MAX, FE_UNDERFLOW }, + { DBL_MAX, DBL_MIN, FE_OVERFLOW }, + { 1.0, 0.0, FE_DIVBYZERO }, + { 0.0, 0.0, FE_INVALID }, + }; + unsigned int x86f, sse2f; fenv_t env, env2; - int ret; + int i, ret, flags; + double res;
p__clearfp();
@@ -806,6 +831,40 @@ static void test_feenv(void) ok(!ret, "fesetenv returned %x\n", ret); ret = p_fegetround(); ok(ret == FE_TONEAREST, "Got unexpected round mode %#x.\n", ret); + + if(p__statusfp2) { + x86f = sse2f = 0; + p__statusfp2(NULL, NULL); + + p__statusfp2(&x86f, NULL); + p__statusfp2(NULL, &sse2f); + + ok(!x86f, "p__statusfp2 set x86 %x\n", x86f); + ok(!sse2f, "p__statusfp2 set sse2 %x\n", sse2f); + } + + flags = 0; + for(i=0; i<ARRAY_SIZE(tests); i++) { + res = tests[i].num / tests[i].denom; This doesn't look reliable. I guess you will need to go with some kind of assembly function to do the computation (or set status word directly). I'm not sure if it's worth it.
Thanks, Piotr