|
nsz |
cb9f87 |
#include <stdint.h>
|
|
nsz |
cb9f87 |
#include <stdio.h>
|
|
nsz |
cb9f87 |
#include "util.h"
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
static struct f_ff t[] = {
|
|
nsz |
cb9f87 |
#include "sanity/sincosf.h"
|
|
nsz |
cb9f87 |
};
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int main(void)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
#pragma STDC FENV_ACCESS ON
|
|
nsz |
cb9f87 |
float ysin, ycos;
|
|
nsz |
cb9f87 |
float dsin, dcos;
|
|
nsz |
cb9f87 |
int e, i, err = 0;
|
|
nsz |
cb9f87 |
struct f_ff *p;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
cb9f87 |
p = t + i;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
if (p->r < 0)
|
|
nsz |
cb9f87 |
continue;
|
|
nsz |
cb9f87 |
fesetround(p->r);
|
|
nsz |
cb9f87 |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
cb9f87 |
sincosf(p->x, &ysin, &ycos);
|
|
nsz |
cb9f87 |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
if (!checkexcept(e, p->e, p->r)) {
|
|
nsz |
cb9f87 |
printf("%s:%d: bad fp exception: %s sincosf(%a)=%a,%a, want %s",
|
|
nsz |
cb9f87 |
p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
|
|
nsz |
cb9f87 |
printf(" got %s\n", estr(e));
|
|
nsz |
cb9f87 |
err++;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
dsin = ulperr(ysin, p->y, p->dy);
|
|
nsz |
cb9f87 |
dcos = ulperr(ycos, p->y2, p->dy2);
|
|
nsz |
cb9f87 |
if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) {
|
|
nsz |
cb9f87 |
printf("%s:%d: %s sincosf(%a) want %a,%a got %a,%a, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
|
|
nsz |
cb9f87 |
p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos,
|
|
nsz |
cb9f87 |
dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2);
|
|
nsz |
cb9f87 |
err++;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
return !!err;
|
|
nsz |
cb9f87 |
}
|