1#include <stdint.h> 2#include <stdio.h> 3#include "mtest.h" 4 5static struct lll_l t[] = { 6#if LDBL_MANT_DIG == 53 7#include "sanity/fma.h" 8#include "special/fma.h" 9#elif LDBL_MANT_DIG == 64 10#include "sanity/fmal.h" 11#include "special/fmal.h" 12#endif 13}; 14 15int main(void) 16{ 17 #pragma STDC FENV_ACCESS ON 18 long double y; 19 float d; 20 int e, i, err = 0; 21 struct lll_l *p; 22 23 for (i = 0; i < sizeof t/sizeof *t; i++) { 24 p = t + i; 25 26 if (p->r < 0) 27 continue; 28 fesetround(p->r); 29 feclearexcept(FE_ALL_EXCEPT); 30 y = fmal(p->x, p->x2, p->x3); 31 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); 32 33 /* do not check inexact by default */ 34#if defined CHECK_INEXACT || defined CHECK_INEXACT_OMISSION 35 if (!checkexceptall(e, p->e, p->r)) { 36#else 37 if (!checkexceptall(e|INEXACT, p->e|INEXACT, p->r)) { 38#endif 39 printf("%s:%d: bad fp exception: %s fmal(%La,%La,%La)=%La, want %s", 40 p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, estr(p->e)); 41 printf(" got %s\n", estr(e)); 42 err++; 43 } 44 d = ulperrl(y, p->y, p->dy); 45 if (!checkcr(y, p->y, p->r)) { 46 printf("%s:%d: %s fmal(%La,%La,%La) want %La got %La ulperr %.3f = %a + %a\n", 47 p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, y, d, d-p->dy, p->dy); 48 err++; 49 } 50 } 51 return !!err; 52} 53