comparison test/call_suite_aggrs/main.c @ 510:f0080b53635d

test/call_suite_aggrs: - less confusing and simpler generated code (with first arg in V_?[0] output) - avoid using same test reference value for retval and last arg
author Tassilo Philipp
date Sat, 09 Apr 2022 23:45:44 +0200
parents ed7d1f5e7973
children c9c546f8598b
comparison
equal deleted inserted replaced
509:f3d44195dbdf 510:f0080b53635d
83 dcBeginCallAggr(p, rtype_a); 83 dcBeginCallAggr(p, rtype_a);
84 } 84 }
85 85
86 86
87 while ( (atype = *sig) != ')') { 87 while ( (atype = *sig) != ')') {
88 pos++;
89 switch(atype) { 88 switch(atype) {
90 case 'c': dcArgChar (p,K_c[pos]); break; 89 case 'c': dcArgChar (p,K_c[pos]); break;
91 case 's': dcArgShort (p,K_s[pos]); break; 90 case 's': dcArgShort (p,K_s[pos]); break;
92 case 'i': dcArgInt (p,K_i[pos]); break; 91 case 'i': dcArgInt (p,K_i[pos]); break;
93 case 'j': dcArgLong (p,K_j[pos]); break; 92 case 'j': dcArgLong (p,K_j[pos]); break;
116 sig += len-1; /* advance to next arg char */ 115 sig += len-1; /* advance to next arg char */
117 break; 116 break;
118 } 117 }
119 default: printf("unknown atype '%c' (1) ;", atype); return 0; 118 default: printf("unknown atype '%c' (1) ;", atype); return 0;
120 } 119 }
120 ++pos;
121 ++sig; 121 ++sig;
122 } 122 }
123 123
124 switch(*rtype) 124 switch(*rtype)
125 { 125 {
126 case 'v': dcCallVoid(p,t); s=1; break; /*TODO:check that no return-arg was touched.*/ 126 case 'v': dcCallVoid(p,t); s=1; break; /*TODO:check that no return-arg was touched.*/
127 case 'c': s = ( dcCallChar (p,t) == K_c[pos]); break; 127 case 'c': s = ( dcCallChar (p,t) == K_c[pos]); break;
128 case 's': s = ( dcCallShort (p,t) == K_s[pos]); break; 128 case 's': s = ( dcCallShort (p,t) == K_s[pos]); break;
139 case 'd': s = ( dcCallDouble (p,t) == K_d[pos]); break; 139 case 'd': s = ( dcCallDouble (p,t) == K_d[pos]); break;
140 case '<': /* union */ 140 case '<': /* union */
141 case '{': /* struct */ 141 case '{': /* struct */
142 { 142 {
143 /* bound check memory adjacent to returned aggregate, to check for overflows by dcCallAggr */ 143 /* bound check memory adjacent to returned aggregate, to check for overflows by dcCallAggr */
144 long long* adj_ll = (get_max_aggr_size() - rtype_size) > sizeof(long long) ? (long long*)((char*)V_a[0] + rtype_size) : NULL; 144 long long* adj_ll = (get_max_aggr_size() - rtype_size) > sizeof(long long) ? (long long*)((char*)V_a[pos] + rtype_size) : NULL;
145 if(adj_ll) 145 if(adj_ll)
146 *adj_ll = 0x0123456789abcdef; 146 *adj_ll = 0x0123456789abcdef;
147 147
148 s = ((int(*)(const void*,const void*))rtype_a_cmp)(dcCallAggr(p, t, rtype_a, V_a[0]), K_a[pos]); 148 s = ((int(*)(const void*,const void*))rtype_a_cmp)(dcCallAggr(p, t, rtype_a, V_a[pos]), K_a[pos]);
149 149
150 if(adj_ll && *adj_ll != 0x0123456789abcdef) { 150 if(adj_ll && *adj_ll != 0x0123456789abcdef) {
151 printf("writing rval overflowed into adjacent memory;"); 151 printf("writing rval overflowed into adjacent memory;");
152 return 0; 152 return 0;
153 } 153 }
158 158
159 if (!s) { printf("rval wrong;"); return 0; } 159 if (!s) { printf("rval wrong;"); return 0; }
160 160
161 /* test V_* array against values passed to func: */ 161 /* test V_* array against values passed to func: */
162 sig = signature; 162 sig = signature;
163 pos = 1; 163 pos = 0;
164 while ( (atype = *sig) != ')') { 164 while ( (atype = *sig) != ')') {
165 switch(atype) { 165 switch(atype) {
166 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_c[pos], K_c[pos]); break; 166 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_c[pos], K_c[pos]); break;
167 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_s[pos], K_s[pos]); break; 167 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_s[pos], K_s[pos]); break;
168 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_i[pos], K_i[pos]); break; 168 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_i[pos], K_i[pos]); break;