math: add ilogb, fix f_fi tests
[libc-test] / src / math / gen / template / f_fi.c
index e697ca5..4a2104e 100644 (file)
@@ -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));
@@ -26,7 +32,7 @@ int main(void)
                        err++;
                }
                d = ulperrf(y, p->y, p->dy);
-               if (!checkulp(d, p->r)) {
+               if (!checkulp(d, p->r) || yi != p->i) {
                        printf("%s:%d: %s ___(%a) want %a,%lld got %a,%d ulperr %.3f = %a + %a\n",
                                p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
                        err++;