add _DEFAULT_SOURCE wherever _BSD_SOURCE was used
[libc-test] / src / math / jnf.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 fi_f t[] = {
9 #include "sanity/jnf.h"
10 #include "special/jnf.h"
11 };
12
13 int main(void)
14 {
15         #pragma STDC FENV_ACCESS ON
16         double y;
17         float d;
18         int e, i, err = 0;
19         struct fi_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 = jnf(p->i, p->x);
29                 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
30
31                 if (!checkexcept(e, p->e, p->r)) {
32                         printf("%s:%d: bad fp exception: %s jnf(%lld, %a)=%a, want %s",
33                                 p->file, p->line, rstr(p->r), p->i, p->x, p->y, estr(p->e));
34                         printf(" got %s\n", estr(e));
35                         err++;
36                 }
37                 d = ulperrf(y, p->y, p->dy);
38                 if (!checkulp(d, p->r)) {
39                         printf("%s:%d: %s jnf(%lld, %a) want %a got %a, ulperr %.3f = %a + %a\n",
40                                 p->file, p->line, rstr(p->r), p->i, p->x, p->y, y, d, d-p->dy, p->dy);
41                         err++;
42                 }
43         }
44         return !!err;
45 }