1 #include <stdarg.h>
2
3 #include "compat-common.h"
4
5 #ifdef SKIP_VA
6 const int test_va = 0;
7 #else
8 const int test_va = 1;
9 #endif
10
11 typedef struct { char c; } Sc;
12 typedef struct { short s; } Ss;
13 typedef struct { int i; } Si;
14 typedef struct { short s; char c; } Ssc;
15 typedef struct { int i; short s; } Sis;
16 typedef struct { char c; short s; int i; } Scsi;
17 typedef struct { char c; int i; short s; } Scis;
18
initSc(Sc * p,int i)19 void initSc (Sc *p, int i) { p->c = i/16; }
initSs(Ss * p,int i)20 void initSs (Ss *p, int i) { p->s = i; }
initSi(Si * p,int i)21 void initSi (Si *p, int i) { p->i = i; }
initSsc(Ssc * p,int i)22 void initSsc (Ssc *p, int i) { p->s = i; p->c = (i/16)+1; }
initSis(Sis * p,int i)23 void initSis (Sis *p, int i) { p->i = i; p->s = i+1; }
initScsi(Scsi * p,int i)24 void initScsi (Scsi *p, int i) { p->c = i/16; p->s = i+1; p->i = i+2; }
initScis(Scis * p,int i)25 void initScis (Scis *p, int i) { p->c = i/16; p->i = i+1; p->s = i+2; }
26
27 #define T(N, TYPE) \
28 struct S##TYPE##N { TYPE i[N]; }; \
29 \
30 extern struct S##TYPE##N g1s##TYPE##N, g2s##TYPE##N; \
31 extern struct S##TYPE##N g3s##TYPE##N, g4s##TYPE##N; \
32 extern struct S##TYPE##N g5s##TYPE##N, g6s##TYPE##N; \
33 extern struct S##TYPE##N g7s##TYPE##N, g8s##TYPE##N; \
34 extern struct S##TYPE##N g9s##TYPE##N, g10s##TYPE##N; \
35 extern struct S##TYPE##N g11s##TYPE##N, g12s##TYPE##N; \
36 extern struct S##TYPE##N g13s##TYPE##N, g14s##TYPE##N; \
37 extern struct S##TYPE##N g15s##TYPE##N, g16s##TYPE##N; \
38 \
39 extern void check##TYPE (TYPE x, int i); \
40 extern void \
41 check##TYPE##N (struct S##TYPE##N *p, int i); \
42 \
43 void \
44 checkg##TYPE##N (void) \
45 { \
46 check##TYPE##N ( &g1s##TYPE##N, 1*16); \
47 check##TYPE##N ( &g2s##TYPE##N, 2*16); \
48 check##TYPE##N ( &g3s##TYPE##N, 3*16); \
49 check##TYPE##N ( &g4s##TYPE##N, 4*16); \
50 check##TYPE##N ( &g5s##TYPE##N, 5*16); \
51 check##TYPE##N ( &g6s##TYPE##N, 6*16); \
52 check##TYPE##N ( &g7s##TYPE##N, 7*16); \
53 check##TYPE##N ( &g8s##TYPE##N, 8*16); \
54 check##TYPE##N ( &g9s##TYPE##N, 9*16); \
55 check##TYPE##N (&g10s##TYPE##N, 10*16); \
56 check##TYPE##N (&g11s##TYPE##N, 11*16); \
57 check##TYPE##N (&g12s##TYPE##N, 12*16); \
58 check##TYPE##N (&g13s##TYPE##N, 13*16); \
59 check##TYPE##N (&g14s##TYPE##N, 14*16); \
60 check##TYPE##N (&g15s##TYPE##N, 15*16); \
61 check##TYPE##N (&g16s##TYPE##N, 16*16); \
62 } \
63 \
64 void \
65 test##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2, \
66 struct S##TYPE##N s3, struct S##TYPE##N s4, \
67 struct S##TYPE##N s5, struct S##TYPE##N s6, \
68 struct S##TYPE##N s7, struct S##TYPE##N s8, \
69 struct S##TYPE##N s9, struct S##TYPE##N s10, \
70 struct S##TYPE##N s11, struct S##TYPE##N s12, \
71 struct S##TYPE##N s13, struct S##TYPE##N s14, \
72 struct S##TYPE##N s15, struct S##TYPE##N s16) \
73 { \
74 check##TYPE##N (&s1, 1*16); \
75 check##TYPE##N (&s2, 2*16); \
76 check##TYPE##N (&s3, 3*16); \
77 check##TYPE##N (&s4, 4*16); \
78 check##TYPE##N (&s5, 5*16); \
79 check##TYPE##N (&s6, 6*16); \
80 check##TYPE##N (&s7, 7*16); \
81 check##TYPE##N (&s8, 8*16); \
82 check##TYPE##N (&s9, 9*16); \
83 check##TYPE##N (&s10, 10*16); \
84 check##TYPE##N (&s11, 11*16); \
85 check##TYPE##N (&s12, 12*16); \
86 check##TYPE##N (&s13, 13*16); \
87 check##TYPE##N (&s14, 14*16); \
88 check##TYPE##N (&s15, 15*16); \
89 check##TYPE##N (&s16, 16*16); \
90 } \
91 \
92 void \
93 testva##TYPE##N (int n, ...) \
94 { \
95 int i; \
96 va_list ap; \
97 if (test_va) \
98 { \
99 va_start (ap, n); \
100 for (i = 0; i < n; i++) \
101 { \
102 struct S##TYPE##N t = va_arg (ap, struct S##TYPE##N); \
103 check##TYPE##N (&t, (i+1)*16); \
104 } \
105 va_end (ap); \
106 } \
107 }
108
109 #ifndef SKIP_ZERO_ARRAY
110 T(0, Sc)
111 #endif
112 T(1, Sc)
113 T(2, Sc)
114 T(3, Sc)
115 T(4, Sc)
116 T(5, Sc)
117 T(6, Sc)
118 T(7, Sc)
119 T(8, Sc)
120 T(9, Sc)
121 T(10, Sc)
122 T(11, Sc)
123 T(12, Sc)
124 T(13, Sc)
125 T(14, Sc)
126 T(15, Sc)
127 #ifndef SKIP_ZERO_ARRAY
128 T(0, Ss)
129 #endif
130 T(1, Ss)
131 T(2, Ss)
132 T(3, Ss)
133 T(4, Ss)
134 T(5, Ss)
135 T(6, Ss)
136 T(7, Ss)
137 T(8, Ss)
138 T(9, Ss)
139 T(10, Ss)
140 T(11, Ss)
141 T(12, Ss)
142 T(13, Ss)
143 T(14, Ss)
144 T(15, Ss)
145 #ifndef SKIP_ZERO_ARRAY
146 T(0, Si)
147 #endif
148 T(1, Si)
149 T(2, Si)
150 T(3, Si)
151 T(4, Si)
152 T(5, Si)
153 T(6, Si)
154 T(7, Si)
155 T(8, Si)
156 T(9, Si)
157 T(10, Si)
158 T(11, Si)
159 T(12, Si)
160 T(13, Si)
161 T(14, Si)
162 T(15, Si)
163