|
nsz |
b5bbc6 |
#include <stdint.h>
|
|
nsz |
b5bbc6 |
#include <stdio.h>
|
|
nsz |
b5bbc6 |
#include "util.h"
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
static struct l_i t[] = {
|
|
nsz |
b5bbc6 |
#if LDBL_MANT_DIG == 53
|
|
nsz |
b5bbc6 |
#include "sanity/lrint.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/lrint.h"
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
b5bbc6 |
#include "sanity/lrintl.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/lrintl.h"
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
#endif
|
|
nsz |
b5bbc6 |
};
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
int main(void)
|
|
nsz |
b5bbc6 |
{
|
|
nsz |
b5bbc6 |
#pragma STDC FENV_ACCESS ON
|
|
nsz |
e08422 |
long long yi;
|
|
nsz |
b5bbc6 |
int e, i, err = 0;
|
|
nsz |
b5bbc6 |
struct l_i *p;
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
b5bbc6 |
p = t + i;
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
if (p->r < 0)
|
|
nsz |
b5bbc6 |
continue;
|
|
nsz |
b5bbc6 |
fesetround(p->r);
|
|
nsz |
b5bbc6 |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
b5bbc6 |
yi = lrintl(p->x);
|
|
nsz |
b5bbc6 |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
b5bbc6 |
|
|
nsz |
b5bbc6 |
if (!checkexcept(e, p->e, p->r)) {
|
|
nsz |
b5bbc6 |
printf("%s:%d: bad fp exception: %s lrintl(%La)=%lld, want %s",
|
|
nsz |
b5bbc6 |
p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
|
|
nsz |
b5bbc6 |
printf(" got %s\n", estr(e));
|
|
nsz |
b5bbc6 |
err++;
|
|
nsz |
b5bbc6 |
}
|
|
Szabolcs Nagy |
b3580f |
if (!(p->e&INVALID) && yi != p->i) {
|
|
nsz |
e08422 |
printf("%s:%d: %s lrintl(%La) want %lld got %lld\n",
|
|
nsz |
b5bbc6 |
p->file, p->line, rstr(p->r), p->x, p->i, yi);
|
|
nsz |
b5bbc6 |
err++;
|
|
nsz |
b5bbc6 |
}
|
|
nsz |
b5bbc6 |
}
|
|
nsz |
b5bbc6 |
return !!err;
|
|
nsz |
b5bbc6 |
}
|