1570af302Sopenharmony_ci#include <stdint.h>
2570af302Sopenharmony_ci#include <stdio.h>
3570af302Sopenharmony_ci#include "util.h"
4570af302Sopenharmony_ci
5570af302Sopenharmony_cistatic struct d_i t[] = {
6570af302Sopenharmony_ciHEADERS
7570af302Sopenharmony_ci};
8570af302Sopenharmony_ci
9570af302Sopenharmony_ciint main(void)
10570af302Sopenharmony_ci{
11570af302Sopenharmony_ci	#pragma STDC FENV_ACCESS ON
12570af302Sopenharmony_ci	long long yi;
13570af302Sopenharmony_ci	int e, i, err = 0;
14570af302Sopenharmony_ci	struct d_i *p;
15570af302Sopenharmony_ci
16570af302Sopenharmony_ci	for (i = 0; i < sizeof t/sizeof *t; i++) {
17570af302Sopenharmony_ci		p = t + i;
18570af302Sopenharmony_ci
19570af302Sopenharmony_ci		if (p->r < 0)
20570af302Sopenharmony_ci			continue;
21570af302Sopenharmony_ci		fesetround(p->r);
22570af302Sopenharmony_ci		feclearexcept(FE_ALL_EXCEPT);
23570af302Sopenharmony_ci		yi = ___(p->x);
24570af302Sopenharmony_ci		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
25570af302Sopenharmony_ci
26570af302Sopenharmony_ci		if (!checkexcept(e, p->e, p->r)) {
27570af302Sopenharmony_ci			printf("%s:%d: bad fp exception: %s ___(%a)=%lld, want %s",
28570af302Sopenharmony_ci				p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
29570af302Sopenharmony_ci			printf(" got %s\n", estr(e));
30570af302Sopenharmony_ci			err++;
31570af302Sopenharmony_ci		}
32570af302Sopenharmony_ci		if (yi != p->i) {
33570af302Sopenharmony_ci			printf("%s:%d: %s ___(%a) want %lld got %lld\n",
34570af302Sopenharmony_ci				p->file, p->line, rstr(p->r), p->x, p->i, yi);
35570af302Sopenharmony_ci			err++;
36570af302Sopenharmony_ci		}
37570af302Sopenharmony_ci	}
38570af302Sopenharmony_ci	return !!err;
39570af302Sopenharmony_ci}
40