add _DEFAULT_SOURCE wherever _BSD_SOURCE was used
[libc-test] / src / math / lgammal.c
1 #define _DEFAULT_SOURCE 1
2 #define _BSD_SOURCE 1
3 #define _XOPEN_SOURCE 700
4 #include <stdint.h>
5 #include <stdio.h>
6 #include "mtest.h"
7
8 static struct l_li t[] = {
9 #if LDBL_MANT_DIG == 53
10 #include "sanity/lgamma.h"
11 #include "special/lgamma.h"
12
13 #elif LDBL_MANT_DIG == 64
14 #include "sanity/lgammal.h"
15 #include "special/lgammal.h"
16
17 #endif
18 };
19
20 int main(void)
21 {
22         #pragma STDC FENV_ACCESS ON
23         int yi;
24         long double y;
25         float d;
26         int e, i, err = 0;
27         struct l_li *p;
28
29         for (i = 0; i < sizeof t/sizeof *t; i++) {
30                 p = t + i;
31
32                 if (p->r < 0)
33                         continue;
34                 fesetround(p->r);
35                 feclearexcept(FE_ALL_EXCEPT);
36                 y = lgammal(p->x);
37                 yi = signgam;
38                 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
39
40                 if (!checkexcept(e, p->e, p->r)) {
41                         printf("%s:%d: bad fp exception: %s lgammal(%La)=%La,%lld, want %s",
42                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
43                         printf(" got %s\n", estr(e));
44                         err++;
45                 }
46                 d = ulperrl(y, p->y, p->dy);
47                 // TODO: 2 ulp errors allowed
48                 if ((p->r==RN && fabs(d) > 2) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) {
49                         printf("%s:%d: %s lgammal(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
50                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
51                         err++;
52                 }
53         }
54         return !!err;
55 }