diff --git a/src/math/Makefile b/src/math/Makefile index e251c6d..8c640ac 100644 --- a/src/math/Makefile +++ b/src/math/Makefile @@ -1,5 +1,5 @@ CFLAGS+=-g -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces -CFLAGS+=-fno-builtin -D_GNU_SOURCE +CFLAGS+=-Wno-unknown-pragmas -fno-builtin -ffloat-store -frounding-math -D_GNU_SOURCE LDFLAGS+=-g -lm SRC=$(sort $(wildcard *.c)) @@ -17,7 +17,7 @@ clean: $(BIN): util.o -%.o: %.c sanity/%.h ucb/%.h crlibm/%.h +%.o: %.c sanity/%.h ucb/%.h crlibm/%.h util.h $(CC) $(CFLAGS) -c -o $@ $< %: %.c %: %.o diff --git a/src/math/acos.c b/src/math/acos.c index f9d28f0..09c1dd2 100644 --- a/src/math/acos.c +++ b/src/math/acos.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acos(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acos(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/acosf.c b/src/math/acosf.c index fb20f89..8a35f06 100644 --- a/src/math/acosf.c +++ b/src/math/acosf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acosf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acosf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/acosh.c b/src/math/acosh.c index 60680c2..c0620d8 100644 --- a/src/math/acosh.c +++ b/src/math/acosh.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acosh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acosh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/acoshf.c b/src/math/acoshf.c index 60ceb58..37a29b9 100644 --- a/src/math/acoshf.c +++ b/src/math/acoshf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acoshf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acoshf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/acoshl.c b/src/math/acoshl.c index 63a7334..d4146ee 100644 --- a/src/math/acoshl.c +++ b/src/math/acoshl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acoshl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acoshl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/acosl.c b/src/math/acosl.c index ecd6f62..5ac9a79 100644 --- a/src/math/acosl.c +++ b/src/math/acosl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = acosl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s acosl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asin.c b/src/math/asin.c index 193264c..64d950c 100644 --- a/src/math/asin.c +++ b/src/math/asin.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asin(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asin(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asinf.c b/src/math/asinf.c index 0fe46b8..38a3e9f 100644 --- a/src/math/asinf.c +++ b/src/math/asinf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asinf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asinf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asinh.c b/src/math/asinh.c index 132e942..fc9e68c 100644 --- a/src/math/asinh.c +++ b/src/math/asinh.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asinh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asinh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asinhf.c b/src/math/asinhf.c index e2681dd..90260e1 100644 --- a/src/math/asinhf.c +++ b/src/math/asinhf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asinhf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asinhf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asinhl.c b/src/math/asinhl.c index b65aff4..8be196e 100644 --- a/src/math/asinhl.c +++ b/src/math/asinhl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asinhl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asinhl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/asinl.c b/src/math/asinl.c index 9fc0982..1084c79 100644 --- a/src/math/asinl.c +++ b/src/math/asinl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = asinl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s asinl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atan.c b/src/math/atan.c index 527aeb2..825f2ce 100644 --- a/src/math/atan.c +++ b/src/math/atan.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atan(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atan(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atan2.c b/src/math/atan2.c index a0b55ab..0772893 100644 --- a/src/math/atan2.c +++ b/src/math/atan2.c @@ -10,6 +10,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atan2(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atan2(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/atan2f.c b/src/math/atan2f.c index 872ef59..e5d742d 100644 --- a/src/math/atan2f.c +++ b/src/math/atan2f.c @@ -10,6 +10,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atan2f(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atan2f(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/atan2l.c b/src/math/atan2l.c index c809e67..d6d5ae4 100644 --- a/src/math/atan2l.c +++ b/src/math/atan2l.c @@ -15,6 +15,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atan2l(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atan2l(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/atanf.c b/src/math/atanf.c index c3f016b..3e35a3c 100644 --- a/src/math/atanf.c +++ b/src/math/atanf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atanf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atanf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atanh.c b/src/math/atanh.c index 55dfa1c..ec41ac5 100644 --- a/src/math/atanh.c +++ b/src/math/atanh.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atanh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atanh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atanhf.c b/src/math/atanhf.c index a772971..3fa6c33 100644 --- a/src/math/atanhf.c +++ b/src/math/atanhf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atanhf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atanhf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atanhl.c b/src/math/atanhl.c index 230c1da..4d986da 100644 --- a/src/math/atanhl.c +++ b/src/math/atanhl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atanhl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atanhl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/atanl.c b/src/math/atanl.c index 0aee4a4..73d7993 100644 --- a/src/math/atanl.c +++ b/src/math/atanl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = atanl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s atanl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cbrt.c b/src/math/cbrt.c index 4faf739..55ecc5a 100644 --- a/src/math/cbrt.c +++ b/src/math/cbrt.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cbrt(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cbrt(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cbrtf.c b/src/math/cbrtf.c index 9737fbb..305d03f 100644 --- a/src/math/cbrtf.c +++ b/src/math/cbrtf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cbrtf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cbrtf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cbrtl.c b/src/math/cbrtl.c index 037a397..79f1749 100644 --- a/src/math/cbrtl.c +++ b/src/math/cbrtl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cbrtl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cbrtl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/ceil.c b/src/math/ceil.c index ab6be5f..65c587d 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ceil(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ceil(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/ceilf.c b/src/math/ceilf.c index dbc18d5..4b0a317 100644 --- a/src/math/ceilf.c +++ b/src/math/ceilf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ceilf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ceilf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/ceill.c b/src/math/ceill.c index 4971447..d3a3ed4 100644 --- a/src/math/ceill.c +++ b/src/math/ceill.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ceill(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ceill(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/copysign.c b/src/math/copysign.c index 2f1464c..1f27fd0 100644 --- a/src/math/copysign.c +++ b/src/math/copysign.c @@ -9,6 +9,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = copysign(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s copysign(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/copysignf.c b/src/math/copysignf.c index 8456a8f..a53f6f2 100644 --- a/src/math/copysignf.c +++ b/src/math/copysignf.c @@ -9,6 +9,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = copysignf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s copysignf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/copysignl.c b/src/math/copysignl.c index 7849aa9..8e21ba1 100644 --- a/src/math/copysignl.c +++ b/src/math/copysignl.c @@ -14,6 +14,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = copysignl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s copysignl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/cos.c b/src/math/cos.c index 74bc57b..485efad 100644 --- a/src/math/cos.c +++ b/src/math/cos.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cos(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cos(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cosf.c b/src/math/cosf.c index cf9aa29..4dc55cd 100644 --- a/src/math/cosf.c +++ b/src/math/cosf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cosf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cosf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cosh.c b/src/math/cosh.c index 29f3ef5..6820d09 100644 --- a/src/math/cosh.c +++ b/src/math/cosh.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cosh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cosh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/coshf.c b/src/math/coshf.c index 955736c..b2ec5b0 100644 --- a/src/math/coshf.c +++ b/src/math/coshf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = coshf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s coshf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/coshl.c b/src/math/coshl.c index 880737a..0dc737e 100644 --- a/src/math/coshl.c +++ b/src/math/coshl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = coshl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s coshl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/cosl.c b/src/math/cosl.c index 8788a95..cb11ddc 100644 --- a/src/math/cosl.c +++ b/src/math/cosl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = cosl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s cosl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erf.c b/src/math/erf.c index 6d085dc..cb60a63 100644 --- a/src/math/erf.c +++ b/src/math/erf.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erfc.c b/src/math/erfc.c index fb9fe9b..6834d5d 100644 --- a/src/math/erfc.c +++ b/src/math/erfc.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erfc(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erfc(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erfcf.c b/src/math/erfcf.c index 39629b0..d226d40 100644 --- a/src/math/erfcf.c +++ b/src/math/erfcf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erfcf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erfcf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erfcl.c b/src/math/erfcl.c index 8720138..4e7ffec 100644 --- a/src/math/erfcl.c +++ b/src/math/erfcl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erfcl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erfcl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erff.c b/src/math/erff.c index 5b95fd3..a399e50 100644 --- a/src/math/erff.c +++ b/src/math/erff.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erff(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erff(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/erfl.c b/src/math/erfl.c index b03cc74..753885d 100644 --- a/src/math/erfl.c +++ b/src/math/erfl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = erfl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erfl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp.c b/src/math/exp.c index 6f27409..e7a77a7 100644 --- a/src/math/exp.c +++ b/src/math/exp.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp10.c b/src/math/exp10.c index dff72a7..49cc61a 100644 --- a/src/math/exp10.c +++ b/src/math/exp10.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp10(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp10(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp10f.c b/src/math/exp10f.c index b0b1645..3ed2232 100644 --- a/src/math/exp10f.c +++ b/src/math/exp10f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp10f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp10f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp10l.c b/src/math/exp10l.c index 273e816..3651a6d 100644 --- a/src/math/exp10l.c +++ b/src/math/exp10l.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp10l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp10l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp2.c b/src/math/exp2.c index 2d2567e..0a1ccb6 100644 --- a/src/math/exp2.c +++ b/src/math/exp2.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp2(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp2(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp2f.c b/src/math/exp2f.c index 02eb8fb..9d29780 100644 --- a/src/math/exp2f.c +++ b/src/math/exp2f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp2f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp2f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/exp2l.c b/src/math/exp2l.c index f283edf..72d6ead 100644 --- a/src/math/exp2l.c +++ b/src/math/exp2l.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = exp2l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s exp2l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/expf.c b/src/math/expf.c index f80c64b..87d8c5c 100644 --- a/src/math/expf.c +++ b/src/math/expf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = expf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s expf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/expl.c b/src/math/expl.c index e65d6e4..6e118df 100644 --- a/src/math/expl.c +++ b/src/math/expl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = expl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s expl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/expm1.c b/src/math/expm1.c index 9780a97..70fdfef 100644 --- a/src/math/expm1.c +++ b/src/math/expm1.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = expm1(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s expm1(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/expm1f.c b/src/math/expm1f.c index 3c1dc94..6f72d47 100644 --- a/src/math/expm1f.c +++ b/src/math/expm1f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = expm1f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s expm1f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/expm1l.c b/src/math/expm1l.c index 1668f63..7950542 100644 --- a/src/math/expm1l.c +++ b/src/math/expm1l.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = expm1l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s expm1l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/fabs.c b/src/math/fabs.c index 1cd8716..6a93081 100644 --- a/src/math/fabs.c +++ b/src/math/fabs.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fabs(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fabs(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/fabsf.c b/src/math/fabsf.c index 4c418b8..1dc99b4 100644 --- a/src/math/fabsf.c +++ b/src/math/fabsf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fabsf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fabsf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/fabsl.c b/src/math/fabsl.c index 5963f51..df170ea 100644 --- a/src/math/fabsl.c +++ b/src/math/fabsl.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fabsl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fabsl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/fdim.c b/src/math/fdim.c index 0857a49..c3177de 100644 --- a/src/math/fdim.c +++ b/src/math/fdim.c @@ -9,6 +9,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fdim(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fdim(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fdimf.c b/src/math/fdimf.c index 1c940b9..56dac2f 100644 --- a/src/math/fdimf.c +++ b/src/math/fdimf.c @@ -9,6 +9,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fdimf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fdimf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fdiml.c b/src/math/fdiml.c index 1f41eda..9f07940 100644 --- a/src/math/fdiml.c +++ b/src/math/fdiml.c @@ -14,6 +14,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fdiml(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fdiml(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/floor.c b/src/math/floor.c index 1e4928f..1a8f809 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = floor(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s floor(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/floorf.c b/src/math/floorf.c index 4b71391..2808f13 100644 --- a/src/math/floorf.c +++ b/src/math/floorf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = floorf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s floorf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/floorl.c b/src/math/floorl.c index a6856e3..42c79de 100644 --- a/src/math/floorl.c +++ b/src/math/floorl.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = floorl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s floorl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/fmax.c b/src/math/fmax.c index 938361c..f0ae9a7 100644 --- a/src/math/fmax.c +++ b/src/math/fmax.c @@ -9,6 +9,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmax(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmax(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmaxf.c b/src/math/fmaxf.c index febb8a7..9268786 100644 --- a/src/math/fmaxf.c +++ b/src/math/fmaxf.c @@ -9,6 +9,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmaxf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmaxf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmaxl.c b/src/math/fmaxl.c index e074e13..5f4f1f3 100644 --- a/src/math/fmaxl.c +++ b/src/math/fmaxl.c @@ -14,6 +14,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmaxl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmaxl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmin.c b/src/math/fmin.c index eae3d64..d18387d 100644 --- a/src/math/fmin.c +++ b/src/math/fmin.c @@ -9,6 +9,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmin(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmin(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fminf.c b/src/math/fminf.c index 5727b73..db85a51 100644 --- a/src/math/fminf.c +++ b/src/math/fminf.c @@ -9,6 +9,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fminf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fminf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fminl.c b/src/math/fminl.c index fb6b17f..aca8246 100644 --- a/src/math/fminl.c +++ b/src/math/fminl.c @@ -14,6 +14,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fminl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fminl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmod.c b/src/math/fmod.c index 8c7765f..3e66c95 100644 --- a/src/math/fmod.c +++ b/src/math/fmod.c @@ -10,6 +10,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmod(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmod(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmodf.c b/src/math/fmodf.c index 3396b4e..d92a7e6 100644 --- a/src/math/fmodf.c +++ b/src/math/fmodf.c @@ -10,6 +10,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmodf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmodf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/fmodl.c b/src/math/fmodl.c index 15486cb..7f715e3 100644 --- a/src/math/fmodl.c +++ b/src/math/fmodl.c @@ -15,6 +15,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = fmodl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmodl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/frexp.c b/src/math/frexp.c index 19bc401..73a415e 100644 --- a/src/math/frexp.c +++ b/src/math/frexp.c @@ -9,6 +9,7 @@ static struct d_di t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = frexp(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s frexp(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/frexpf.c b/src/math/frexpf.c index e4f05c1..f43da51 100644 --- a/src/math/frexpf.c +++ b/src/math/frexpf.c @@ -9,6 +9,7 @@ static struct f_fi t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = frexpf(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s frexpf(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/frexpl.c b/src/math/frexpl.c index 9d56bf2..275e979 100644 --- a/src/math/frexpl.c +++ b/src/math/frexpl.c @@ -14,6 +14,7 @@ static struct l_li t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; long double y; float d; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = frexpl(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s frexpl(%La)=%La,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/gen/template/d_d.c b/src/math/gen/template/d_d.c index 9a7ba82..36bd0c5 100644 --- a/src/math/gen/template/d_d.c +++ b/src/math/gen/template/d_d.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/gen/template/d_di.c b/src/math/gen/template/d_di.c index 3b224fa..efe20fd 100644 --- a/src/math/gen/template/d_di.c +++ b/src/math/gen/template/d_di.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/gen/template/dd_d.c b/src/math/gen/template/dd_d.c index 2f46d1d..9537e98 100644 --- a/src/math/gen/template/dd_d.c +++ b/src/math/gen/template/dd_d.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/gen/template/di_d.c b/src/math/gen/template/di_d.c index 43fa506..bedd3cb 100644 --- a/src/math/gen/template/di_d.c +++ b/src/math/gen/template/di_d.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/gen/template/f_f.c b/src/math/gen/template/f_f.c index 4538c6b..d5aa993 100644 --- a/src/math/gen/template/f_f.c +++ b/src/math/gen/template/f_f.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/gen/template/f_fi.c b/src/math/gen/template/f_fi.c index e697ca5..1e19a4c 100644 --- a/src/math/gen/template/f_fi.c +++ b/src/math/gen/template/f_fi.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/gen/template/ff_f.c b/src/math/gen/template/ff_f.c index 6b3ae58..30c64bc 100644 --- a/src/math/gen/template/ff_f.c +++ b/src/math/gen/template/ff_f.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/gen/template/fi_f.c b/src/math/gen/template/fi_f.c index b989822..d6b0b0d 100644 --- a/src/math/gen/template/fi_f.c +++ b/src/math/gen/template/fi_f.c @@ -8,6 +8,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/gen/template/l_l.c b/src/math/gen/template/l_l.c index 82c9003..54e589d 100644 --- a/src/math/gen/template/l_l.c +++ b/src/math/gen/template/l_l.c @@ -12,6 +12,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -19,9 +20,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/gen/template/l_li.c b/src/math/gen/template/l_li.c index 1bfa9de..32c6a0e 100644 --- a/src/math/gen/template/l_li.c +++ b/src/math/gen/template/l_li.c @@ -12,6 +12,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON int yi; long double y; float d; @@ -20,9 +21,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%La)=%La,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/gen/template/li_l.c b/src/math/gen/template/li_l.c index b11e461..540fa2d 100644 --- a/src/math/gen/template/li_l.c +++ b/src/math/gen/template/li_l.c @@ -12,6 +12,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -19,9 +20,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%La, %lld)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/gen/template/ll_l.c b/src/math/gen/template/ll_l.c index 09178bd..962cce4 100644 --- a/src/math/gen/template/ll_l.c +++ b/src/math/gen/template/ll_l.c @@ -12,6 +12,7 @@ HEADERS int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -19,9 +20,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ___(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/hypot.c b/src/math/hypot.c index eef74b1..842ceb4 100644 --- a/src/math/hypot.c +++ b/src/math/hypot.c @@ -10,6 +10,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = hypot(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s hypot(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/hypotf.c b/src/math/hypotf.c index 91f5a2d..7b47807 100644 --- a/src/math/hypotf.c +++ b/src/math/hypotf.c @@ -10,6 +10,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = hypotf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s hypotf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/hypotl.c b/src/math/hypotl.c index d84c6c8..290bc80 100644 --- a/src/math/hypotl.c +++ b/src/math/hypotl.c @@ -15,6 +15,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = hypotl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s hypotl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/j0.c b/src/math/j0.c index c40d4f0..e1faf28 100644 --- a/src/math/j0.c +++ b/src/math/j0.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = j0(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s j0(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/j0f.c b/src/math/j0f.c index 94a213c..6349596 100644 --- a/src/math/j0f.c +++ b/src/math/j0f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = j0f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s j0f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/j1.c b/src/math/j1.c index 4d620f9..c21721b 100644 --- a/src/math/j1.c +++ b/src/math/j1.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = j1(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s j1(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/j1f.c b/src/math/j1f.c index c6efdb7..38123fb 100644 --- a/src/math/j1f.c +++ b/src/math/j1f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = j1f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s j1f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/ldexp.c b/src/math/ldexp.c index 7605945..4ab011f 100644 --- a/src/math/ldexp.c +++ b/src/math/ldexp.c @@ -9,6 +9,7 @@ static struct di_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ldexp(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ldexp(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/ldexpf.c b/src/math/ldexpf.c index dd0f8b8..01b037c 100644 --- a/src/math/ldexpf.c +++ b/src/math/ldexpf.c @@ -9,6 +9,7 @@ static struct fi_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ldexpf(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ldexpf(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/ldexpl.c b/src/math/ldexpl.c index ddd867b..f1c6439 100644 --- a/src/math/ldexpl.c +++ b/src/math/ldexpl.c @@ -14,6 +14,7 @@ static struct li_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = ldexpl(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ldexpl(%La, %lld)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/lgamma.c b/src/math/lgamma.c index 301a967..d76538f 100644 --- a/src/math/lgamma.c +++ b/src/math/lgamma.c @@ -9,6 +9,7 @@ static struct d_di t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,10 +18,15 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgamma(p->x); yi = signgam; - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgamma(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/lgamma_r.c b/src/math/lgamma_r.c index 87ccada..c2acb99 100644 --- a/src/math/lgamma_r.c +++ b/src/math/lgamma_r.c @@ -9,6 +9,7 @@ static struct d_di t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgamma_r(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgamma_r(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/lgammaf.c b/src/math/lgammaf.c index 0ac09fc..47051e3 100644 --- a/src/math/lgammaf.c +++ b/src/math/lgammaf.c @@ -9,6 +9,7 @@ static struct f_fi t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,10 +18,15 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgammaf(p->x); yi = signgam; - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgammaf(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/lgammaf_r.c b/src/math/lgammaf_r.c index a81b644..11ca8e3 100644 --- a/src/math/lgammaf_r.c +++ b/src/math/lgammaf_r.c @@ -9,6 +9,7 @@ static struct f_fi t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; double y; float d; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgammaf_r(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgammaf_r(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/lgammal.c b/src/math/lgammal.c index ef25118..d282de2 100644 --- a/src/math/lgammal.c +++ b/src/math/lgammal.c @@ -14,6 +14,7 @@ static struct l_li t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; long double y; float d; @@ -22,10 +23,15 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgammal(p->x); yi = signgam; - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgammal(%La)=%La,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/lgammal_r.c b/src/math/lgammal_r.c index bfb8efc..2ebe612 100644 --- a/src/math/lgammal_r.c +++ b/src/math/lgammal_r.c @@ -14,6 +14,7 @@ static struct l_li t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON int yi; long double y; float d; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = lgammal_r(p->x, &yi); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgammal_r(%La)=%La,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); diff --git a/src/math/log.c b/src/math/log.c index c0150f2..5e5d5c4 100644 --- a/src/math/log.c +++ b/src/math/log.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log10.c b/src/math/log10.c index d93d600..91558cd 100644 --- a/src/math/log10.c +++ b/src/math/log10.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log10(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log10(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log10f.c b/src/math/log10f.c index d9cf952..90689f5 100644 --- a/src/math/log10f.c +++ b/src/math/log10f.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log10f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log10f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log10l.c b/src/math/log10l.c index d5fea94..5548ec7 100644 --- a/src/math/log10l.c +++ b/src/math/log10l.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log10l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log10l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log1p.c b/src/math/log1p.c index 8824d1c..0f96339 100644 --- a/src/math/log1p.c +++ b/src/math/log1p.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log1p(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log1p(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log1pf.c b/src/math/log1pf.c index e1ae18a..fb738f6 100644 --- a/src/math/log1pf.c +++ b/src/math/log1pf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log1pf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log1pf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log1pl.c b/src/math/log1pl.c index 08964bd..07b0afa 100644 --- a/src/math/log1pl.c +++ b/src/math/log1pl.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log1pl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log1pl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log2.c b/src/math/log2.c index 283c813..25b8b2e 100644 --- a/src/math/log2.c +++ b/src/math/log2.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log2(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log2(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log2f.c b/src/math/log2f.c index 333fc85..75e5991 100644 --- a/src/math/log2f.c +++ b/src/math/log2f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log2f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log2f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/log2l.c b/src/math/log2l.c index 28e2b3f..a1a7315 100644 --- a/src/math/log2l.c +++ b/src/math/log2l.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = log2l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s log2l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/logb.c b/src/math/logb.c index 52fcbb0..597bd51 100644 --- a/src/math/logb.c +++ b/src/math/logb.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = logb(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s logb(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/logbf.c b/src/math/logbf.c index 7595cf1..12f4757 100644 --- a/src/math/logbf.c +++ b/src/math/logbf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = logbf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s logbf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/logbl.c b/src/math/logbl.c index 6cb7005..2c70eda 100644 --- a/src/math/logbl.c +++ b/src/math/logbl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = logbl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s logbl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/logf.c b/src/math/logf.c index aa5863c..fbead36 100644 --- a/src/math/logf.c +++ b/src/math/logf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = logf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s logf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/logl.c b/src/math/logl.c index c1a534f..c9c27be 100644 --- a/src/math/logl.c +++ b/src/math/logl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = logl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s logl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/nearbyint.c b/src/math/nearbyint.c index 988555f..927f129 100644 --- a/src/math/nearbyint.c +++ b/src/math/nearbyint.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nearbyint(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nearbyint(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/nearbyintf.c b/src/math/nearbyintf.c index 7f65ba2..13de8ed 100644 --- a/src/math/nearbyintf.c +++ b/src/math/nearbyintf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nearbyintf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nearbyintf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/nearbyintl.c b/src/math/nearbyintl.c index d819f25..9bbc94e 100644 --- a/src/math/nearbyintl.c +++ b/src/math/nearbyintl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nearbyintl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nearbyintl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/nextafter.c b/src/math/nextafter.c index edf62e9..02c6edc 100644 --- a/src/math/nextafter.c +++ b/src/math/nextafter.c @@ -8,6 +8,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nextafter(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nextafter(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/nextafterf.c b/src/math/nextafterf.c index 2550bbd..e0aae93 100644 --- a/src/math/nextafterf.c +++ b/src/math/nextafterf.c @@ -8,6 +8,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nextafterf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nextafterf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/nextafterl.c b/src/math/nextafterl.c index cbdf287..23b94fd 100644 --- a/src/math/nextafterl.c +++ b/src/math/nextafterl.c @@ -12,6 +12,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -19,9 +20,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nextafterl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nextafterl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/nexttowardl.c b/src/math/nexttowardl.c index 19525dd..f38c36e 100644 --- a/src/math/nexttowardl.c +++ b/src/math/nexttowardl.c @@ -12,6 +12,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -19,9 +20,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = nexttowardl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s nexttowardl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/pow.c b/src/math/pow.c index ef7129b..f705f17 100644 --- a/src/math/pow.c +++ b/src/math/pow.c @@ -11,6 +11,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = pow(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s pow(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/pow10.c b/src/math/pow10.c index a487aa5..c85b517 100644 --- a/src/math/pow10.c +++ b/src/math/pow10.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = pow10(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s pow10(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/pow10f.c b/src/math/pow10f.c index 74f53f4..fd2a485 100644 --- a/src/math/pow10f.c +++ b/src/math/pow10f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = pow10f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s pow10f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/pow10l.c b/src/math/pow10l.c index c1d2a23..3f1abae 100644 --- a/src/math/pow10l.c +++ b/src/math/pow10l.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = pow10l(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s pow10l(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/powf.c b/src/math/powf.c index 054671a..f11c260 100644 --- a/src/math/powf.c +++ b/src/math/powf.c @@ -10,6 +10,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = powf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s powf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/powl.c b/src/math/powl.c index 7c94362..8ceb6f1 100644 --- a/src/math/powl.c +++ b/src/math/powl.c @@ -16,6 +16,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = powl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s powl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/remainder.c b/src/math/remainder.c index 45321a5..4faa6d4 100644 --- a/src/math/remainder.c +++ b/src/math/remainder.c @@ -9,6 +9,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = remainder(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s remainder(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/remainderf.c b/src/math/remainderf.c index bbaebcb..6156c98 100644 --- a/src/math/remainderf.c +++ b/src/math/remainderf.c @@ -9,6 +9,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = remainderf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s remainderf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/remainderl.c b/src/math/remainderl.c index 08305e7..5ce0f97 100644 --- a/src/math/remainderl.c +++ b/src/math/remainderl.c @@ -14,6 +14,7 @@ static struct ll_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = remainderl(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s remainderl(%La,%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/rint.c b/src/math/rint.c index e4e1009..5cadc61 100644 --- a/src/math/rint.c +++ b/src/math/rint.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = rint(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s rint(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/rintf.c b/src/math/rintf.c index 707fdb1..6fc6f5a 100644 --- a/src/math/rintf.c +++ b/src/math/rintf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = rintf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s rintf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/rintl.c b/src/math/rintl.c index 331796c..bda368e 100644 --- a/src/math/rintl.c +++ b/src/math/rintl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = rintl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s rintl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/round.c b/src/math/round.c index fa6e3b7..a3fd5e9 100644 --- a/src/math/round.c +++ b/src/math/round.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = round(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s round(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/roundf.c b/src/math/roundf.c index 78a5dae..d572d94 100644 --- a/src/math/roundf.c +++ b/src/math/roundf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = roundf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s roundf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/roundl.c b/src/math/roundl.c index 53c0b53..f4fa024 100644 --- a/src/math/roundl.c +++ b/src/math/roundl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = roundl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s roundl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/scalb.c b/src/math/scalb.c index 133f077..88b529b 100644 --- a/src/math/scalb.c +++ b/src/math/scalb.c @@ -8,6 +8,7 @@ static struct dd_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalb(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalb(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/scalbf.c b/src/math/scalbf.c index 6fe28a9..d91dff4 100644 --- a/src/math/scalbf.c +++ b/src/math/scalbf.c @@ -8,6 +8,7 @@ static struct ff_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -15,9 +16,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalbf(p->x, p->x2); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalbf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); diff --git a/src/math/scalbln.c b/src/math/scalbln.c index a53dc39..0231ceb 100644 --- a/src/math/scalbln.c +++ b/src/math/scalbln.c @@ -9,6 +9,7 @@ static struct di_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalbln(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalbln(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/scalblnf.c b/src/math/scalblnf.c index ccb7eec..f80c3fc 100644 --- a/src/math/scalblnf.c +++ b/src/math/scalblnf.c @@ -9,6 +9,7 @@ static struct fi_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalblnf(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalblnf(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/scalblnl.c b/src/math/scalblnl.c index b06c407..71ef477 100644 --- a/src/math/scalblnl.c +++ b/src/math/scalblnl.c @@ -14,6 +14,7 @@ static struct li_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalblnl(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalblnl(%La, %lld)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/scalbn.c b/src/math/scalbn.c index 317d082..99fdc1b 100644 --- a/src/math/scalbn.c +++ b/src/math/scalbn.c @@ -9,6 +9,7 @@ static struct di_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalbn(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalbn(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/scalbnf.c b/src/math/scalbnf.c index 5391264..de588a2 100644 --- a/src/math/scalbnf.c +++ b/src/math/scalbnf.c @@ -9,6 +9,7 @@ static struct fi_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalbnf(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalbnf(%a, %lld)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/scalbnl.c b/src/math/scalbnl.c index fe26540..05ad3d9 100644 --- a/src/math/scalbnl.c +++ b/src/math/scalbnl.c @@ -14,6 +14,7 @@ static struct li_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = scalbnl(p->x, p->i); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s scalbnl(%La, %lld)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e)); diff --git a/src/math/sin.c b/src/math/sin.c index 0eb1b10..1500162 100644 --- a/src/math/sin.c +++ b/src/math/sin.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sin(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sin(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sinf.c b/src/math/sinf.c index efb695a..4b8c427 100644 --- a/src/math/sinf.c +++ b/src/math/sinf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sinf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sinf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sinh.c b/src/math/sinh.c index d57f629..08e1a0f 100644 --- a/src/math/sinh.c +++ b/src/math/sinh.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sinh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sinh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sinhf.c b/src/math/sinhf.c index ba0556e..d67f91c 100644 --- a/src/math/sinhf.c +++ b/src/math/sinhf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sinhf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sinhf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sinhl.c b/src/math/sinhl.c index 05b4adb..654292d 100644 --- a/src/math/sinhl.c +++ b/src/math/sinhl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sinhl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sinhl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sinl.c b/src/math/sinl.c index 73ce9f0..399baf6 100644 --- a/src/math/sinl.c +++ b/src/math/sinl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sinl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sinl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sqrt.c b/src/math/sqrt.c index 09dbb31..29ff800 100644 --- a/src/math/sqrt.c +++ b/src/math/sqrt.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sqrt(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sqrt(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sqrtf.c b/src/math/sqrtf.c index 7c00fd0..6c3fb04 100644 --- a/src/math/sqrtf.c +++ b/src/math/sqrtf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sqrtf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sqrtf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/sqrtl.c b/src/math/sqrtl.c index 4b8c9f4..24d5b59 100644 --- a/src/math/sqrtl.c +++ b/src/math/sqrtl.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = sqrtl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sqrtl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tan.c b/src/math/tan.c index 1751e6d..86c69b4 100644 --- a/src/math/tan.c +++ b/src/math/tan.c @@ -11,6 +11,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -18,9 +19,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tan(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tan(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tanf.c b/src/math/tanf.c index 4b69e6f..5e0759a 100644 --- a/src/math/tanf.c +++ b/src/math/tanf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tanf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tanf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tanh.c b/src/math/tanh.c index 59d6676..59376e1 100644 --- a/src/math/tanh.c +++ b/src/math/tanh.c @@ -10,6 +10,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tanh(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tanh(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tanhf.c b/src/math/tanhf.c index 3c46171..effeb49 100644 --- a/src/math/tanhf.c +++ b/src/math/tanhf.c @@ -10,6 +10,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -17,9 +18,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tanhf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tanhf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tanhl.c b/src/math/tanhl.c index 1f35a06..af9629b 100644 --- a/src/math/tanhl.c +++ b/src/math/tanhl.c @@ -15,6 +15,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -22,9 +23,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tanhl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tanhl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tanl.c b/src/math/tanl.c index 8165b36..c4980ab 100644 --- a/src/math/tanl.c +++ b/src/math/tanl.c @@ -16,6 +16,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -23,9 +24,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tanl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tanl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tgamma.c b/src/math/tgamma.c index d67270f..f286a62 100644 --- a/src/math/tgamma.c +++ b/src/math/tgamma.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tgamma(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tgamma(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tgammaf.c b/src/math/tgammaf.c index 424e3c7..4d841a4 100644 --- a/src/math/tgammaf.c +++ b/src/math/tgammaf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tgammaf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tgammaf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/tgammal.c b/src/math/tgammal.c index 28bc4a8..6bfffeb 100644 --- a/src/math/tgammal.c +++ b/src/math/tgammal.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = tgammal(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s tgammal(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/trunc.c b/src/math/trunc.c index 5d09d84..49c50e0 100644 --- a/src/math/trunc.c +++ b/src/math/trunc.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = trunc(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s trunc(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/truncf.c b/src/math/truncf.c index 5eebc7e..1df8781 100644 --- a/src/math/truncf.c +++ b/src/math/truncf.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = truncf(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s truncf(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/truncl.c b/src/math/truncl.c index 686343f..11125b2 100644 --- a/src/math/truncl.c +++ b/src/math/truncl.c @@ -14,6 +14,7 @@ static struct l_l t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; @@ -21,9 +22,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = truncl(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s truncl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/util.c b/src/math/util.c index 3875695..1892173 100644 --- a/src/math/util.c +++ b/src/math/util.c @@ -127,15 +127,3 @@ char *rstr(int r) } return "R?"; } - -void setupfenv(int r) -{ - fesetround(r); - feclearexcept(FE_ALL_EXCEPT); -} - -int getexcept(void) -{ - return fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); -} - diff --git a/src/math/util.h b/src/math/util.h index 10d9279..b24046d 100644 --- a/src/math/util.h +++ b/src/math/util.h @@ -82,31 +82,25 @@ struct li_l {POS int r; long double x; long long i; long double y; float dy; int char *estr(int); char *rstr(int); -int rconv(int *, char *); -int econv(int *, char *); - -int eulp(double); -int eulpf(float); -int eulpl(long double); float ulperr(double got, double want, float dwant); float ulperrf(float got, float want, float dwant); float ulperrl(long double got, long double want, float dwant); -void setupfenv(int); -int getexcept(void); - static int checkexcept(int got, int want, int r) { + // TODO: we dont checkunderflow and inexact for now if (r == RN) - return got == want || got == (want|INEXACT); - return 1; //(got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW); + return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW); +// return got == want || got == (want|INEXACT); + return 1; } static int checkulp(float d, int r) { + // TODO: we only care about >=1.5 ulp errors for now, should be 1.0 if (r == RN) - return fabsf(d) <= 1.0; - return 1; //fabsf(d) <= 2.0; + return fabsf(d) < 1.5; + return 1; } diff --git a/src/math/y0.c b/src/math/y0.c index 41edba4..2998660 100644 --- a/src/math/y0.c +++ b/src/math/y0.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = y0(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s y0(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/y0f.c b/src/math/y0f.c index 4ff83f7..3b74777 100644 --- a/src/math/y0f.c +++ b/src/math/y0f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = y0f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s y0f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/y1.c b/src/math/y1.c index 166293b..a5e3b6a 100644 --- a/src/math/y1.c +++ b/src/math/y1.c @@ -9,6 +9,7 @@ static struct d_d t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON double y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = y1(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s y1(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); diff --git a/src/math/y1f.c b/src/math/y1f.c index 3498434..d396b61 100644 --- a/src/math/y1f.c +++ b/src/math/y1f.c @@ -9,6 +9,7 @@ static struct f_f t[] = { int main(void) { + #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; @@ -16,9 +17,14 @@ int main(void) for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; - setupfenv(p->r); + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); y = y1f(p->x); - e = getexcept(); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s y1f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));