Mercurial > pub > dyncall > dyncall
annotate test/callf/main.c @ 613:3c3e321875f7
- adding helper target to cmake
author | Tassilo Philipp |
---|---|
date | Sat, 01 Oct 2022 16:03:25 +0200 |
parents | b1f2b574d772 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: test | |
5 File: test/callf/main.c | |
379 | 6 Description: |
0 | 7 License: |
8 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
9 Copyright (c) 2007-2022 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 | |
28 /* test dcCallF API */ | |
29 | |
30 #include "../../dyncall/dyncall_callf.h" | |
31 #include "../common/platformInit.h" | |
32 #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ | |
33 | |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
34 #include <stdarg.h> |
608 | 35 #if defined(DC__Feature_Syscall) |
36 # if defined(DC_UNIX) && !defined(DC__OS_BeOS) && !defined(DC__OS_Minix) | |
37 # include <sys/syscall.h> | |
38 # endif | |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
39 #endif |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
40 |
0 | 41 |
42 /* sample void function */ | |
43 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
44 int i_iii(int x,int y,int z) |
0 | 45 { |
46 int r = (x == 1 && y == 2 && z == 3); | |
47 printf("%d %d %d: %d", x, y, z, r); | |
48 return r; | |
49 } | |
50 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
51 int i_ffiffiffi(float a, float b, int c, float d, float e, int f, float g, float h, int i) |
0 | 52 { |
53 int r = (a == 1.f && b == 2.f && c == 3 && d == 4.f && e == 5.f && f == 6 && g == 7.f && h == 8.f && i == 9); | |
54 printf("%f %f %d %f %f %d %f %f %d: %d", a, b, c, d, e, f, g, h, i, r); | |
55 return r; | |
56 } | |
57 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
58 int i_ffiV(float a, float b, int c, ...) |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
59 { |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
60 va_list ap; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
61 double d, e, g, h; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
62 int f, i; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
63 int r; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
64 |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
65 va_start(ap, c); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
66 d = va_arg(ap, double); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
67 e = va_arg(ap, double); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
68 f = va_arg(ap, int); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
69 g = va_arg(ap, double); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
70 h = va_arg(ap, double); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
71 i = va_arg(ap, int); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
72 va_end(ap); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
73 |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
74 r = (a == 1.f && b == 2.f && c == 3 && d == 4. && e == 5. && f == 6 && g == 7. && h == 8. && i == 9); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
75 printf("%f %f %d %f %f %d %f %f %d: %d", a, b, c, d, e, f, g, h, i, r); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
76 return r; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
77 } |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
78 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
79 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
80 #if defined(DC__Feature_AggrByVal) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
81 struct A { int i; char x[7]; long long dummy_too_big_for_regs[50]; }; /* returned via hidden ptr arg on x64/sysv */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
82 struct A A_cc(char a, char b) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
83 { |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
84 int i; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
85 struct A r = { (int)a-(int)b, { 3, a|b } }; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
86 for(i=2; i<7; ++i) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
87 r.x[i] = r.x[i-2]+r.x[i-1]; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
88 printf("%d %d: ", a, b); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
89 return r; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
90 } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
91 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
92 struct B { int i; unsigned char x[7]; }; /* returned via regs on x64/sysv */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
93 struct B A_CC(unsigned char a, unsigned char b) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
94 { |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
95 int i; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
96 struct B r = { (int)a-(int)b, { 3, a|b } }; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
97 for(i=2; i<7; ++i) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
98 r.x[i] = r.x[i-2]+r.x[i-1]; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
99 printf("%d %d: ", a, b); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
100 return r; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
101 } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
102 #endif |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
103 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
104 |
0 | 105 /* main */ |
106 | |
107 int main(int argc, char* argv[]) | |
108 { | |
109 DCCallVM* vm; | |
110 DCValue ret; | |
111 int r = 1; | |
112 | |
113 dcTest_initPlatform(); | |
114 | |
115 /* allocate call vm */ | |
116 vm = dcNewCallVM(4096); | |
117 | |
118 | |
119 /* calls using 'formatted' API */ | |
120 dcReset(vm); | |
121 printf("callf iii)i: "); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
122 dcCallF(vm, &ret, (void*)&i_iii, "iii)i", 1, 2, 3); |
0 | 123 r = ret.i && r; |
124 | |
125 dcReset(vm); | |
126 printf("\ncallf ffiffiffi)i: "); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
127 dcCallF(vm, &ret, (void*)&i_ffiffiffi, "ffiffiffi)i", 1.f, 2.f, 3, 4.f, 5.f, 6, 7.f, 8.f, 9); |
0 | 128 r = ret.i && r; |
129 | |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
130 /* same but with calling convention prefix */ |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
131 dcReset(vm); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
132 printf("\ncallf _:ffiffiffi)i: "); |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
133 dcCallF(vm, &ret, (void*)&i_ffiffiffi, "_:ffiffiffi)i", 1.f, 2.f, 3, 4.f, 5.f, 6, 7.f, 8.f, 9); |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
134 r = ret.i && r; |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
135 |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
136 /* vararg call */ |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
137 dcReset(vm); |
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
138 printf("\ncallf _effi_.ddiddi)i: "); |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
139 dcCallF(vm, &ret, (void*)&i_ffiV, "_effi_.ddiddi)i", 1.f, 2.f, 3, 4., 5., 6, 7., 8., 9); |
358
30aae7371373
- extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents:
281
diff
changeset
|
140 r = ret.i && r; |
0 | 141 |
142 /* arg binding then call using 'formatted' API */ | |
143 dcReset(vm); | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
363
diff
changeset
|
144 /* reset calling convention too */ |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
363
diff
changeset
|
145 dcMode(vm, DC_CALL_C_DEFAULT); |
0 | 146 printf("\nargf iii)i then call: "); |
147 dcArgF(vm, "iii)i", 1, 2, 3); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
148 r = r && dcCallInt(vm, (void*)&i_iii); |
0 | 149 |
150 dcReset(vm); | |
151 printf("\nargf iii then call: "); | |
152 dcArgF(vm, "iii", 1, 2, 3); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
153 r = r && dcCallInt(vm, (void*)&i_iii); |
0 | 154 |
155 dcReset(vm); | |
156 printf("\nargf ffiffiffi)i then call: "); | |
157 dcArgF(vm, "ffiffiffi)i", 1.f, 2.f, 3, 4.f, 5.f, 6, 7.f, 8.f, 9); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
158 r = r && dcCallInt(vm, (void*)&i_ffiffiffi); |
0 | 159 |
160 dcReset(vm); | |
161 printf("\nargf ffiffiffi then call: "); | |
162 dcArgF(vm, "ffiffiffi", 1.f, 2.f, 3, 4.f, 5.f, 6, 7.f, 8.f, 9); | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
163 r = r && dcCallInt(vm, (void*)&i_ffiffiffi); |
0 | 164 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
165 #if defined(DC__Feature_Syscall) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
166 # if defined(DC_UNIX) |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
167 /* testing syscall using calling convention prefix - not available on all platforms */ |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
168 dcReset(vm); |
363 | 169 printf("\ncallf _$iZi)i"); |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
170 fflush(NULL); /* needed before syscall write as it's immediate, or order might be incorrect */ |
363 | 171 dcCallF(vm, &ret, (DCpointer)(ptrdiff_t)SYS_write, "_$iZi)i", 1/*stdout*/, " = syscall: 1", 13); |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
172 r = ret.i == 13 && r; |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
173 # else |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
174 /*@@@*/ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
175 # endif |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
176 #endif |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
177 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
178 #if defined(DC__Feature_AggrByVal) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
179 /* aggregate return value test */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
180 { |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
181 int r_; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
182 struct A a; |
600
d9558c1555df
test/callf: dcNewAggr() calls param fixes, used wrong field count
Tassilo Philipp
parents:
533
diff
changeset
|
183 DCaggr *s = dcNewAggr(2, sizeof(struct A)); |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
184 dcAggrField(s, DC_SIGCHAR_INT, offsetof(struct A, i), 1); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
185 dcAggrField(s, DC_SIGCHAR_CHAR, offsetof(struct A, x), 7); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
186 dcCloseAggr(s); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
187 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
188 dcReset(vm); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
189 printf("\ncallf _:cc)A (A={ic[7]l[50]}): "); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
190 dcCallF(vm, &ret, (void*)&A_cc, "_:cc)A", 3, 16, s, &a); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
191 r_ = ret.p == &a && a.i == -13 && a.x[0] == 3 && a.x[1] == 19 && a.x[2] == 22 && a.x[3] == 41 && a.x[4] == 63 && a.x[5] == 104 && a.x[6] == -89; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
192 printf("%d %d %d %d %d %d %d %d: %d", a.i, a.x[0], a.x[1], a.x[2], a.x[3], a.x[4], a.x[5], a.x[6], r_); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
193 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
194 dcFreeAggr(s); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
195 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
196 r = r_ && r; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
197 } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
198 /* aggregate return value test */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
199 { |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
200 int r_; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
201 struct B b; |
600
d9558c1555df
test/callf: dcNewAggr() calls param fixes, used wrong field count
Tassilo Philipp
parents:
533
diff
changeset
|
202 DCaggr *s = dcNewAggr(2, sizeof(struct B)); |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
203 dcAggrField(s, DC_SIGCHAR_INT, offsetof(struct B, i), 1); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
204 dcAggrField(s, DC_SIGCHAR_UCHAR, offsetof(struct B, x), 7); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
205 dcCloseAggr(s); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
206 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
207 dcReset(vm); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
208 printf("\ncallf _:cc)A (A={iC[7]}): "); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
209 dcCallF(vm, &ret, (void*)&A_CC, "_:CC)A", 3, 16, s, &b); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
210 r_ = ret.p == &b && b.i == -13 && b.x[0] == 3 && b.x[1] == 19 && b.x[2] == 22 && b.x[3] == 41 && b.x[4] == 63 && b.x[5] == 104 && b.x[6] == 167; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
211 printf("%d %d %d %d %d %d %d %d: %d", b.i, b.x[0], b.x[1], b.x[2], b.x[3], b.x[4], b.x[5], b.x[6], r_); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
212 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
213 dcFreeAggr(s); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
214 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
215 r = r_ && r; |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
410
diff
changeset
|
216 } |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
358
diff
changeset
|
217 #endif |
0 | 218 |
219 /* free vm */ | |
220 dcFree(vm); | |
221 | |
222 printf("\nresult: callf: %d\n", r); | |
223 | |
224 dcTest_deInitPlatform(); | |
379 | 225 |
410
7608e34098b0
- cleanups, simplifications, some api clarification, ...
Tassilo Philipp
parents:
387
diff
changeset
|
226 return !r; |
0 | 227 } |
228 |