1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct l_li t[] = {
6 #if LDBL_MANT_DIG == 53
7 DHEADERS
8 #elif LDBL_MANT_DIG == 64
9 HEADERS
10 #endif
11 };
12
main(void)13 int main(void)
14 {
15 #pragma STDC FENV_ACCESS ON
16 int yi;
17 long double y;
18 float d;
19 int e, i, err = 0;
20 struct l_li *p;
21
22 for (i = 0; i < sizeof t/sizeof *t; i++) {
23 p = t + i;
24
25 if (p->r < 0)
26 continue;
27 fesetround(p->r);
28 feclearexcept(FE_ALL_EXCEPT);
29 y = ___(p->x, &yi);
30 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
31
32 if (!checkexcept(e, p->e, p->r)) {
33 printf("%s:%d: bad fp exception: %s ___(%La)=%La,%lld, want %s",
34 p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
35 printf(" got %s\n", estr(e));
36 err++;
37 }
38 d = ulperrl(y, p->y, p->dy);
39 if (!checkulp(d, p->r) || yi != p->i) {
40 printf("%s:%d: %s ___(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
41 p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
42 err++;
43 }
44 }
45 return !!err;
46 }
47