(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
dfp/
fe-check.h
       1  /* Common support for checking that appropriate floating point exceptions
       2     are raised for decimal float operations.  These tests are here to test
       3     the software decimal float support in libgcc.  */
       4  
       5  #include "dfp-dbg.h"
       6  #include "dfp-except.h"
       7  
       8  #if defined(DBG) || defined(DBG2)
       9  #include <stdio.h>
      10  #undef FAILURE
      11  #define FAILURE(NUM,KIND,EXCEPT) \
      12    { printf ("failed for test %d: %s %s\n", NUM, KIND, EXCEPT); failures++; }
      13  #else
      14  #undef FAILURE
      15  #define FAILURE(N,K,E) __builtin_abort ();
      16  #endif
      17  
      18  /* This is useful when modifying the test to make sure that tests are
      19     actually run.  */
      20  #if defined(DBG2)
      21  #define SUCCESS(NUM,EXCEPT) \
      22    { printf ("passed for test %d: %s\n", NUM, EXCEPT); }
      23  #else
      24  #define SUCCESS(N,E) ;
      25  #endif
      26  
      27  #define CHECKFLAG(NUM,EXCEPT,GOT,WANT)				\
      28    if ((WANT & EXCEPT) != (GOT & EXCEPT))			\
      29      {								\
      30        if ((WANT & EXCEPT) != 0)					\
      31          FAILURE (NUM, "missing", #EXCEPT)			\
      32        else							\
      33          FAILURE (NUM, "unexpected", #EXCEPT)			\
      34      }								\
      35    else								\
      36      SUCCESS (NUM, #EXCEPT)
      37  
      38  void
      39  checkflags (int num, int want)
      40  {
      41    int got = DFP_TEST_EXCEPT (FE_ALL_EXCEPT);
      42    CHECKFLAG (num, FE_INVALID, got, want)
      43    CHECKFLAG (num, FE_OVERFLOW, got, want)
      44    CHECKFLAG (num, FE_UNDERFLOW, got, want)
      45    CHECKFLAG (num, FE_DIVBYZERO, got, want)
      46    CHECKFLAG (num, FE_INEXACT, got, want)
      47  }
      48  
      49  #define BINOP(NUM,OP,VAR1,VAL1,VAR2,VAL2,VAR3,EXCEPT)		\
      50  void								\
      51  binop_##NUM (void)						\
      52  {								\
      53    VAR1 = VAL1;							\
      54    VAR2 = VAL2;							\
      55    DFP_CLEAR_EXCEPT (FE_ALL_EXCEPT);				\
      56    VAR3 = VAR1 OP VAR2;						\
      57    checkflags (NUM, EXCEPT);					\
      58  }
      59  
      60  #define CONVERT(NUM,FROM,TO,VALUE,EXCEPT)			\
      61  void								\
      62  convert_##NUM (void)						\
      63  {								\
      64    FROM = VALUE;							\
      65    DFP_CLEAR_EXCEPT (FE_ALL_EXCEPT);				\
      66    TO = FROM;							\
      67    checkflags (NUM, EXCEPT);					\
      68  }