|
Szabolcs Nagy |
2c671f |
#define _DEFAULT_SOURCE 1
|
|
Szabolcs Nagy |
7b5ccd |
#define _BSD_SOURCE 1
|
|
Szabolcs Nagy |
7b5ccd |
#define _GNU_SOURCE 1
|
|
nsz |
75aab9 |
#include <stdint.h>
|
|
nsz |
75aab9 |
#include <stdio.h>
|
|
Szabolcs Nagy |
cfa23c |
#include "mtest.h"
|
|
nsz |
75aab9 |
|
|
nsz |
75aab9 |
static struct d_di t[] = {
|
|
nsz |
75aab9 |
#include "sanity/lgamma_r.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/lgamma_r.h"
|
|
nsz |
75aab9 |
|
|
nsz |
75aab9 |
};
|
|
nsz |
75aab9 |
|
|
nsz |
75aab9 |
int main(void)
|
|
nsz |
75aab9 |
{
|
|
nsz |
d22f4f |
#pragma STDC FENV_ACCESS ON
|
|
nsz |
75aab9 |
int yi;
|
|
nsz |
75aab9 |
double y;
|
|
nsz |
75aab9 |
float d;
|
|
Szabolcs Nagy |
5fc943 |
int e, i, bad, err = 0;
|
|
nsz |
75aab9 |
struct d_di *p;
|
|
nsz |
75aab9 |
|
|
nsz |
75aab9 |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
75aab9 |
p = t + i;
|
|
nsz |
d22f4f |
|
|
nsz |
d22f4f |
if (p->r < 0)
|
|
nsz |
d22f4f |
continue;
|
|
nsz |
d22f4f |
fesetround(p->r);
|
|
nsz |
d22f4f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
75aab9 |
y = lgamma_r(p->x, &yi);
|
|
nsz |
d22f4f |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
d22f4f |
|
|
nsz |
75aab9 |
if (!checkexcept(e, p->e, p->r)) {
|
|
nsz |
75aab9 |
printf("%s:%d: bad fp exception: %s lgamma_r(%a)=%a,%lld, want %s",
|
|
nsz |
75aab9 |
p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
|
|
nsz |
75aab9 |
printf(" got %s\n", estr(e));
|
|
nsz |
75aab9 |
err++;
|
|
nsz |
75aab9 |
}
|
|
nsz |
75aab9 |
d = ulperr(y, p->y, p->dy);
|
|
Szabolcs Nagy |
5fc943 |
bad = !isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i;
|
|
Szabolcs Nagy |
5fc943 |
if (bad || !checkulp(d, p->r)) {
|
|
Szabolcs Nagy |
5fc943 |
if (!bad && fabsf(d) < 11.0f)
|
|
Szabolcs Nagy |
5fc943 |
printf("X ");
|
|
Szabolcs Nagy |
5fc943 |
else
|
|
Szabolcs Nagy |
5fc943 |
err++;
|
|
nsz |
75aab9 |
printf("%s:%d: %s lgamma_r(%a) want %a,%lld got %a,%d ulperr %.3f = %a + %a\n",
|
|
nsz |
75aab9 |
p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
|
|
nsz |
75aab9 |
}
|
|
nsz |
75aab9 |
}
|
|
nsz |
75aab9 |
return !!err;
|
|
nsz |
75aab9 |
}
|