add _DEFAULT_SOURCE wherever _BSD_SOURCE was used
[libc-test] / src / math / j0f.c
1 #define _DEFAULT_SOURCE 1
2 #define _BSD_SOURCE 1
3 #define _GNU_SOURCE 1
4 #include <stdint.h>
5 #include <stdio.h>
6 #include "mtest.h"
7
8 static struct f_f t[] = {
9 #include "sanity/j0f.h"
10 #include "special/j0f.h"
11
12 };
13
14 int main(void)
15 {
16         #pragma STDC FENV_ACCESS ON
17         float y;
18         float d;
19         int e, i, err = 0;
20         struct f_f *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 = j0f(p->x);
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 j0f(%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                 d = ulperrf(y, p->y, p->dy);
39                 if (!checkulp(d, p->r)) {
40 //                      printf("%s:%d: %s j0f(%a) want %a got %a ulperr %.3f = %a + %a\n",
41 //                              p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
42                         err++;
43                         // TODO: avoid spamming the output
44                         printf(__FILE__ ": known to be broken near zeros\n");
45                         break;
46                 }
47         }
48         return !!err;
49 }