comparison test/suite_aggrs/main.c @ 438:b4ddad459690

suite_aggr; - made generator produce unique signatures - reduced dcNewStruct() calls to once only per sig - added missing free()s - cleanup: removal of unused decl, func renaming for clarity, static for tu-local symbols, ...
author Tassilo Philipp
date Wed, 26 Jan 2022 13:37:19 +0100
parents a29baee68340
children e4ae6753a276
comparison
equal deleted inserted replaced
437:135c7fb49c2f 438:b4ddad459690
28 #include <string.h> 28 #include <string.h>
29 #include "../common/platformInit.h" 29 #include "../common/platformInit.h"
30 #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ 30 #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */
31 31
32 32
33 void* G_callvm; 33 static void* G_callvm;
34 34
35 35
36 static int find_agg_idx(int* len, const char* sig) 36 static int find_agg_idx(int* len, const char* sig)
37 { 37 {
38 for(int i=0; i<G_naggs; ++i) { 38 for(int i=0; i<G_naggs; ++i) {
68 return 0; 68 return 0;
69 } 69 }
70 rtype = *sig; 70 rtype = *sig;
71 sig += len; 71 sig += len;
72 72
73 rtype_st_cmp = G_agg_cmpfuncs[i]; 73 rtype_st_cmp = G_agg_cmpfuncs[i];
74 rtype_st = ((DCstruct*(*)())G_agg_newdcstfuncs[i])(); 74 rtype_st = ((DCstruct*(*)())G_agg_touchdcstfuncs[i])();
75 dcBeginCallStruct(p, rtype_st, DC_FALSE); 75 dcBeginCallStruct(p, rtype_st);
76 } 76 }
77 else 77 else
78 rtype = *sig++; 78 rtype = *sig++;
79 79
80 sig_args = sig; 80 sig_args = sig;
96 int i = find_agg_idx(&len, sig); 96 int i = find_agg_idx(&len, sig);
97 if(i == -1) { 97 if(i == -1) {
98 printf("unknown sig at '%s' ;", sig); 98 printf("unknown sig at '%s' ;", sig);
99 return 0; 99 return 0;
100 } 100 }
101 DCstruct *st = ((DCstruct*(*)())G_agg_newdcstfuncs[i])(); 101 DCstruct *st = ((DCstruct*(*)())G_agg_touchdcstfuncs[i])();
102 dcArgStruct(p, st, K_a[pos]); 102 dcArgStruct(p, st, K_a[pos]);
103 sig += len-1; /* advance to next arg char */ 103 sig += len-1; /* advance to next arg char */
104 break; 104 break;
105 } 105 }
106 default: printf("unknown atype '%c' (1) ;", atype); return 0; 106 default: printf("unknown atype '%c' (1) ;", atype); return 0;
118 case 'l': s = (dcCallLongLong(p,t) == K_l[pos]) ; break; 118 case 'l': s = (dcCallLongLong(p,t) == K_l[pos]) ; break;
119 case 'p': s = (dcCallPointer (p,t) == K_p[pos]) ; break; 119 case 'p': s = (dcCallPointer (p,t) == K_p[pos]) ; break;
120 case 'f': s = (dcCallFloat (p,t) == K_f[pos]) ; break; 120 case 'f': s = (dcCallFloat (p,t) == K_f[pos]) ; break;
121 case 'd': s = (dcCallDouble (p,t) == K_d[pos]) ; break; 121 case 'd': s = (dcCallDouble (p,t) == K_d[pos]) ; break;
122 case '{': { 122 case '{': {
123 s = ((int(*)())rtype_st_cmp)(dcCallStruct(p,t,rtype_st, V_a[pos]), K_a[pos]); 123 s = ((int(*)(const void*,const void*))rtype_st_cmp)(dcCallStruct(p,t,rtype_st, V_a[pos]), K_a[pos]);
124 break; 124 break;
125 } 125 }
126 default: printf("unknown rtype '%c'", rtype); return 0; 126 default: printf("unknown rtype '%c'", rtype); return 0;
127 } 127 }
128 128
129 if (!s) { printf("rval wrong;"); return 0; } 129 if (!s) { printf("rval wrong;"); return 0; }
130 130
143 case 'd': s = ( V_d[pos] == K_d[pos] ); if (!s) printf("'d':%d: %f != %f ; ", pos, V_d[pos], K_d[pos]); break; 143 case 'd': s = ( V_d[pos] == K_d[pos] ); if (!s) printf("'d':%d: %f != %f ; ", pos, V_d[pos], K_d[pos]); break;
144 case '{': { 144 case '{': {
145 /* no check: guaranteed to exist, or invoke func would've exited when passing args, above */ 145 /* no check: guaranteed to exist, or invoke func would've exited when passing args, above */
146 int len; 146 int len;
147 int i = find_agg_idx(&len, sig); 147 int i = find_agg_idx(&len, sig);
148 s = ((int(*)())G_agg_cmpfuncs[i])(V_a[pos], K_a[pos]); 148 s = ((int(*)(const void*,const void*))G_agg_cmpfuncs[i])(V_a[pos], K_a[pos]);
149 if (!s) printf("'{':%d: *%p != *%p ; ", pos, V_a[pos], K_a[pos]); 149 if (!s) printf("'{':%d: *%p != *%p ; ", pos, V_a[pos], K_a[pos]);
150 sig += len-1; /* advance to next arg char */ 150 sig += len-1; /* advance to next arg char */
151 break; 151 break;
152 } 152 }
153 default: printf("unknown atype '%c' ; ", atype); return 0; 153 default: printf("unknown atype '%c' ; ", atype); return 0;
185 return !failure; 185 return !failure;
186 } 186 }
187 187
188 int main(int argc, char* argv[]) 188 int main(int argc, char* argv[])
189 { 189 {
190 int total; 190 int total, i;
191 191
192 dcTest_initPlatform(); 192 dcTest_initPlatform();
193 193
194 init_K(G_maxargs); 194 init_test_data(G_maxargs);
195 G_callvm = (DCCallVM*) dcNewCallVM(32768); 195 G_callvm = (DCCallVM*) dcNewCallVM(32768);
196
196 dcReset(G_callvm); 197 dcReset(G_callvm);
197 total = run_all(); 198 total = run_all();
199
200 /* free all DCstructs created on the fly */
201 for(i=0; i<G_naggs; ++i)
202 dcFreeStruct(((DCstruct*(*)())G_agg_touchdcstfuncs[i])());
203
204 dcFree(G_callvm);
205 deinit_test_data(G_maxargs);
206
198 printf("result: call_aggrs: %d\n", total); 207 printf("result: call_aggrs: %d\n", total);
199 208
200 dcTest_deInitPlatform(); 209 dcTest_deInitPlatform();
201 210
202 return !total; 211 return !total;