1 #include "compat-common.h"
2 
3 #ifdef SKIP_VA
4 const int test_va = 0;
5 #else
6 const int test_va = 1;
7 #endif
8 
9 #define T(NAME, TYPE, INITVAL) 					\
10 TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME;		\
11 TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME;		\
12 TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME;		\
13 TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME;		\
14 								\
15 extern void init##NAME (TYPE *p, TYPE v);			\
16 extern void checkg##NAME (void);				\
17 extern TYPE test0##NAME (void);					\
18 extern TYPE test1##NAME (TYPE);					\
19 extern TYPE testva##NAME (int n, ...);				\
20 								\
21 void								\
22 check##NAME (TYPE x, TYPE v)					\
23 {								\
24   if (x != v)							\
25     DEBUG_CHECK							\
26 }								\
27 								\
28 void								\
29 testit##NAME (void)						\
30 {								\
31   TYPE rslt;							\
32   DEBUG_FPUTS (#NAME);						\
33   DEBUG_FPUTS (" init: ");					\
34   init##NAME (&g01##NAME,  1);					\
35   init##NAME (&g02##NAME,  2);					\
36   init##NAME (&g03##NAME,  3);					\
37   init##NAME (&g04##NAME,  4);					\
38   init##NAME (&g05##NAME,  5);					\
39   init##NAME (&g06##NAME,  6);					\
40   init##NAME (&g07##NAME,  7);					\
41   init##NAME (&g08##NAME,  8);					\
42   init##NAME (&g09##NAME,  9);					\
43   init##NAME (&g10##NAME, 10);					\
44   init##NAME (&g11##NAME, 11);					\
45   init##NAME (&g12##NAME, 12);					\
46   init##NAME (&g13##NAME, 13);					\
47   init##NAME (&g14##NAME, 14);					\
48   init##NAME (&g15##NAME, 15);					\
49   init##NAME (&g16##NAME, 16);					\
50   checkg##NAME ();						\
51   DEBUG_NL;							\
52   DEBUG_FPUTS (#NAME);						\
53   DEBUG_FPUTS (" test0: ");					\
54   rslt = test0##NAME ();					\
55   check##NAME (rslt, g01##NAME);				\
56   DEBUG_NL;							\
57   DEBUG_FPUTS (#NAME);						\
58   DEBUG_FPUTS (" test1: ");					\
59   rslt = test1##NAME (g01##NAME);				\
60   check##NAME (rslt, g01##NAME);				\
61   if (test_va)							\
62     {								\
63       DEBUG_NL;							\
64       DEBUG_FPUTS (#NAME);					\
65       DEBUG_FPUTS (" testva:");					\
66       rslt = testva##NAME (1, g01##NAME);			\
67       check##NAME (rslt, g01##NAME);				\
68       rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME,	\
69 			   g04##NAME, g05##NAME);		\
70       check##NAME (rslt, g05##NAME);				\
71       rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME,	\
72 			   g04##NAME, g05##NAME, g06##NAME,	\
73 			   g07##NAME, g08##NAME, g09##NAME);	\
74       check##NAME (rslt, g09##NAME);				\
75       rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME,	\
76 			   g04##NAME, g05##NAME, g06##NAME,	\
77 			   g07##NAME, g08##NAME, g09##NAME,	\
78 			   g10##NAME, g11##NAME, g12##NAME,	\
79 			   g13##NAME, g14##NAME, g15##NAME,	\
80 			   g16##NAME);				\
81       check##NAME (rslt, g16##NAME);				\
82     }								\
83   DEBUG_NL;							\
84 }
85 
86 T(d32, _Decimal32, 1.2df)
87 T(d64, _Decimal64, 12.34dd)
88 T(d128, _Decimal128, 123.456dl)
89 
90 #undef T
91 
92 void
scalar_return_dfp_x()93 scalar_return_dfp_x ()
94 {
95 DEBUG_INIT
96 
97 #define T(NAME) testit##NAME ();
98 
99 T(d32)
100 T(d64)
101 T(d128)
102 
103 DEBUG_FINI
104 
105 if (fails != 0)
106   abort ();
107 
108 #undef T
109 }
110