math: in lgamma* only check signgam when it's specified
[libc-test] / src / math / lgammal.c
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 #include "sanity/lgamma.h"
8 #include "special/lgamma.h"
9
10 #elif LDBL_MANT_DIG == 64
11 #include "sanity/lgammal.h"
12 #include "special/lgammal.h"
13
14 #endif
15 };
16
17 int main(void)
18 {
19         #pragma STDC FENV_ACCESS ON
20         int yi;
21         long double y;
22         float d;
23         int e, i, err = 0;
24         struct l_li *p;
25
26         for (i = 0; i < sizeof t/sizeof *t; i++) {
27                 p = t + i;
28
29                 if (p->r < 0)
30                         continue;
31                 fesetround(p->r);
32                 feclearexcept(FE_ALL_EXCEPT);
33                 y = lgammal(p->x);
34                 yi = signgam;
35                 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
36
37                 if (!checkexcept(e, p->e, p->r)) {
38                         printf("%s:%d: bad fp exception: %s lgammal(%La)=%La,%lld, want %s",
39                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
40                         printf(" got %s\n", estr(e));
41                         err++;
42                 }
43                 d = ulperrl(y, p->y, p->dy);
44                 if (!checkulp(d, p->r) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) {
45                         printf("%s:%d: %s lgammal(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
46                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
47                         err++;
48                 }
49         }
50         return !!err;
51 }