fgetwc may clobber errno when the result is not WEOF
[libc-test.git] / src / math / tgammal.c
blob3ec926000bbc5e0cc2c63eab7153669a621709a9
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "mtest.h"
5 static struct l_l t[] = {
6 #if LDBL_MANT_DIG == 53
7 #include "sanity/tgamma.h"
8 #include "special/tgamma.h"
10 #elif LDBL_MANT_DIG == 64
11 #include "sanity/tgammal.h"
12 #include "special/tgammal.h"
14 #endif
17 int main(void)
19 #pragma STDC FENV_ACCESS ON
20 long double y;
21 float d;
22 int e, i, err = 0;
23 struct l_l *p;
25 for (i = 0; i < sizeof t/sizeof *t; i++) {
26 p = t + i;
28 if (p->r < 0)
29 continue;
30 fesetround(p->r);
31 feclearexcept(FE_ALL_EXCEPT);
32 y = tgammal(p->x);
33 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
35 if (!checkexcept(e, p->e, p->r)) {
36 printf("%s:%d: bad fp exception: %s tgammal(%La)=%La, want %s",
37 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
38 printf(" got %s\n", estr(e));
39 err++;
41 d = ulperrl(y, p->y, p->dy);
42 // TODO: 2 ulp errors allowed
43 if (p->r==RN && fabs(d)>2) {
44 printf("%s:%d: %s tgammal(%La) want %La got %La ulperr %.3f = %a + %a\n",
45 p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
46 err++;
49 return !!err;