1 #define _DEFAULT_SOURCE 1
2 #define _BSD_SOURCE 1
3 #include <stdint.h>
4 #include <stdio.h>
5 #include "mtest.h"
6
7 static struct f_f t[] = {
8 #include "sanity/y0f.h"
9 #include "special/y0f.h"
10
11 };
12
main(void)13 int main(void)
14 {
15 #pragma STDC FENV_ACCESS ON
16 float y;
17 float d;
18 int e, i, bad, err = 0;
19 struct f_f *p;
20
21 for (i = 0; i < sizeof t/sizeof *t; i++) {
22 p = t + i;
23
24 if (p->r < 0)
25 continue;
26 fesetround(p->r);
27 feclearexcept(FE_ALL_EXCEPT);
28 y = y0f(p->x);
29 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
30
31 #ifndef __aarch64__
32 if (!checkexcept(e, p->e, p->r)) {
33 printf("%s:%d: bad fp exception: %s y0f(%a)=%a, want %s",
34 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
35 printf(" got %s\n", estr(e));
36 err++;
37 }
38 #endif
39 d = ulperrf(y, p->y, p->dy);
40 bad = p->x < 0 && !isnan(y) && y != -inf;
41 if (bad || (!(p->x < 0) && !checkulp(d, p->r))) {
42 if (!bad && fabsf(d) < 0x1p23f)
43 printf("X ");
44 else
45 err++;
46 printf("%s:%d: %s y0f(%a) want %a got %a ulperr %.3f = %a + %a\n",
47 p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
48 }
49 }
50 return !!err;
51 }
52