Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_callvm_ppc32.c @ 520:bb4933eab7d6
- call_suite_aggrs: makefile fix
author | Tassilo Philipp |
---|---|
date | Mon, 11 Apr 2022 22:49:04 +0200 |
parents | ddfb9577a00e |
children | 71c884e610f0 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_callvm_ppc32.c | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
6 Description: |
0 | 7 License: |
8 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
9 Copyright (c) 2007-2020 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 /* | |
29 | |
30 dyncall callvm for ppc32 architectures | |
31 | |
32 SUPPORTED CALLING CONVENTIONS | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
33 ppc32/osx |
0 | 34 ppc32/linux (sysv abi) |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
35 ppc32/syscall |
0 | 36 |
37 REVISION | |
38 2015/01/15 added syscall (tested on Linux) | |
39 2009/01/09 added System V ABI support | |
40 2007/12/11 initial support for Darwin ABI | |
41 | |
42 */ | |
43 | |
44 #include "dyncall_callvm_ppc32.h" | |
45 #include "dyncall_alloc.h" | |
46 #include "dyncall_macros.h" | |
47 #include "dyncall_types.h" | |
48 #include "dyncall_utils.h" | |
49 | |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
50 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
51 /* |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
52 ** PowerPC 32-bit calling convention call |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
53 ** |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
54 ** - hybrid return-type call (bool ... pointer) |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
55 ** |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
56 */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
57 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
58 /* Darwin ABI */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
59 void dcCall_ppc32_darwin(DCpointer target, DCRegData_ppc32* ppc32data, DCsize stksize, DCpointer stkdata); |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
60 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
61 /* System V ABI */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
62 void dcCall_ppc32_sysv(DCpointer target, DCRegData_ppc32* ppc32data, DCsize stksize, DCpointer stkdata); |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
63 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
64 /* syscall @@@ Bus Error on Darwin */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
65 void dcCall_ppc32_syscall(DCpointer target, DCRegData_ppc32* ppc32data, DCsize stksize, DCpointer stkdata); |
0 | 66 /* Support for Mac OS X (Darwin) and Systen V ABI for Power PC 32-bit */ |
67 | |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
281
diff
changeset
|
68 |
184 | 69 #if defined(DC_UNIX) |
70 # if defined(DC__OS_Darwin) | |
71 # define DC__ABI_Darwin | |
72 # else | |
73 # define DC__ABI_SysV | |
74 # endif | |
0 | 75 #else |
84 | 76 # error Unsupported OS for ppc32 architecture. |
0 | 77 #endif |
78 | |
79 static void dc_callvm_free_ppc32(DCCallVM* in_self) | |
80 { | |
81 dcFreeMem(in_self); | |
82 } | |
83 | |
84 static void dc_callvm_reset_ppc32(DCCallVM* in_self) | |
85 { | |
86 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
87 dcVecReset(&self->mVecHead); | |
88 self->mIntRegs = 0; | |
89 self->mFloatRegs = 0; | |
90 } | |
91 | |
92 /* OS X/Darwin: fillup integer register file AND push on stack (for ellipsis) */ | |
93 | |
94 static void dc_callvm_argInt_ppc32_darwin(DCCallVM* in_self, DCint i) | |
95 { | |
96 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
97 /* fillup integer register file */ | |
98 if (self->mIntRegs < 8) | |
99 self->mRegData.mIntData[self->mIntRegs++] = i; | |
100 /* AND push onto stack */ | |
101 dcVecAppend(&self->mVecHead,&i,sizeof(DCint)); | |
102 } | |
103 | |
104 static void dc_callvm_argInt_ppc32_sysv(DCCallVM* in_self, DCint i) | |
105 { | |
106 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
107 /* fillup integer register file */ | |
108 if (self->mIntRegs < 8) | |
109 self->mRegData.mIntData[self->mIntRegs++] = i; | |
110 /* OR push onto stack */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
111 else |
0 | 112 dcVecAppend(&self->mVecHead,&i,sizeof(DCint)); |
113 } | |
114 | |
115 /** floating-point **/ | |
116 | |
117 /* double*/ | |
118 | |
119 static void dc_callvm_argDouble_ppc32_darwin(DCCallVM* in_self, DCdouble d) | |
120 { | |
121 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
122 if (self->mFloatRegs < 13) { | |
123 self->mRegData.mFloatData[self->mFloatRegs++] = d; | |
124 /* skip two integer register file entries */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
125 if (self->mIntRegs < 8) |
0 | 126 self->mRegData.mIntData[self->mIntRegs++] = ( (DCint*) &d )[0]; |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
127 if (self->mIntRegs < 8) |
0 | 128 self->mRegData.mIntData[self->mIntRegs++] = ( (DCint*) &d )[1]; |
129 } | |
130 /* push on stack */ | |
131 dcVecAppend(&self->mVecHead, &d, sizeof(DCdouble)); | |
132 } | |
133 | |
134 #if 0 | |
135 static void dc_callvm_argDouble_ppc32_sysv(DCCallVM* in_self, DCdouble d) | |
136 { | |
137 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
138 if (self->mFloatRegs < 8) { | |
139 self->mRegData.mFloatData[self->mFloatRegs++] = d; | |
140 /* skip two integer register file entries */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
141 if (self->mIntRegs < 8) |
0 | 142 self->mRegData.mIntData[self->mIntRegs++] = ( (DCint*) &d )[0]; |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
143 if (self->mIntRegs < 8) |
0 | 144 self->mRegData.mIntData[self->mIntRegs++] = ( (DCint*) &d )[1]; |
145 } | |
146 /* push on stack */ | |
147 dcVecAppend(&self->mVecHead, &d, sizeof(DCdouble)); | |
148 } | |
149 #endif | |
150 static void dc_callvm_argDouble_ppc32_sysv(DCCallVM* in_self, DCdouble d) | |
151 { | |
152 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
153 if (self->mFloatRegs < 8) |
0 | 154 self->mRegData.mFloatData[self->mFloatRegs++] = d; |
155 else /* OR push data on stack */ | |
156 { | |
157 /* align stack to 8 byte boundary */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
158 dcVecResize(&self->mVecHead , ( dcVecSize(&self->mVecHead) + 7UL ) & -8UL ); |
0 | 159 /* AND push data */ |
160 dcVecAppend(&self->mVecHead,(DCpointer) &d,sizeof(DCdouble)); | |
161 } | |
162 } | |
163 | |
164 /* Floating-point */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
165 |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
166 |
0 | 167 /* darwin: |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
168 * - skip one integer register file entry (write in - for ellipsis calls) |
0 | 169 * sysv: |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
170 * - |
0 | 171 */ |
172 | |
173 static void dc_callvm_argFloat_ppc32_darwin(DCCallVM* in_self, DCfloat f) | |
174 { | |
175 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
176 if (self->mFloatRegs < 13) { | |
177 self->mRegData.mFloatData[self->mFloatRegs++] = (DCdouble) (f); | |
178 } | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
179 |
0 | 180 /* AND skip one integer register file entry (write in - for ellipsis calls) */ |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
181 |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
182 if (self->mIntRegs < 8) |
0 | 183 self->mRegData.mIntData[self->mIntRegs++] = *( (DCint*) &f ); |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
184 |
0 | 185 /* AND push on stack */ |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
186 |
0 | 187 dcVecAppend(&self->mVecHead, &f, sizeof(DCfloat)); |
188 } | |
189 | |
190 static void dc_callvm_argFloat_ppc32_sysv(DCCallVM* in_self, DCfloat f) | |
191 { | |
192 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
193 | |
194 /* Put as float register (casted to double) */ | |
195 | |
196 if (self->mFloatRegs < 8) | |
197 self->mRegData.mFloatData[self->mFloatRegs++] = (DCdouble) (f); | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
198 |
0 | 199 else /* OR put float on stack */ |
200 dcVecAppend(&self->mVecHead, &f, sizeof(DCfloat)); | |
201 } | |
202 | |
203 /* long long integer */ | |
204 | |
205 static void dc_callvm_argLongLong_ppc32_darwin(DCCallVM* in_self, DClonglong L) | |
206 { | |
207 DCint* p = (DCint*) &L; | |
208 dcArgInt(in_self, p[0]); | |
209 dcArgInt(in_self, p[1]); | |
210 } | |
211 | |
212 static void dc_callvm_argLongLong_ppc32_sysv(DCCallVM* in_self, DClonglong L) | |
213 { | |
214 DCint* p = (DCint*) &L; | |
215 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
216 /* fillup integer register file */ | |
217 if (self->mIntRegs < 7) | |
218 { | |
219 /* next free integer register is even (r0, r2, r3) ? */ | |
220 /* if not, skip one integer */ | |
221 if (self->mIntRegs & 1) self->mIntRegs++; | |
222 | |
223 self->mRegData.mIntData[self->mIntRegs++] = p[0]; | |
224 self->mRegData.mIntData[self->mIntRegs++] = p[1]; | |
225 } | |
226 /* OR push onto stack */ | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
227 else |
0 | 228 { |
229 /* in case, mIntRegs == 7, set it to 8 */ | |
230 self->mIntRegs = 8; | |
231 /* align stack to 8 byte boundary */ | |
232 dcVecResize(&self->mVecHead , ( dcVecSize(&self->mVecHead) + 7 ) & (-8UL) ); | |
233 /* push data */ | |
234 dcVecAppend(&self->mVecHead,&L,sizeof(DClonglong)); | |
235 } | |
236 } | |
237 | |
238 | |
239 static void dc_callvm_argBool_ppc32(DCCallVM* in_self, DCbool x) | |
240 { | |
241 /* promote to integer */ | |
242 dcArgInt(in_self, (x == 0) ? DC_FALSE : DC_TRUE ); | |
243 } | |
244 | |
245 | |
246 static void dc_callvm_argChar_ppc32(DCCallVM* in_self, DCchar ch) | |
247 { | |
248 /* promote to integer */ | |
249 dcArgInt(in_self, (DCint) ch ); | |
250 } | |
251 | |
252 | |
253 static void dc_callvm_argShort_ppc32(DCCallVM* in_self, DCshort s) | |
254 { | |
255 /* promote to integer */ | |
256 dcArgInt(in_self, (DCint) s ); | |
257 } | |
258 | |
259 | |
260 static void dc_callvm_argLong_ppc32(DCCallVM* in_self, DClong l) | |
261 { | |
262 /* promote to integer */ | |
263 dcArgInt(in_self, (DCint) l ); | |
264 } | |
265 | |
266 static void dc_callvm_argPointer_ppc32(DCCallVM* in_self, DCpointer p) | |
267 { | |
268 /* promote to integer */ | |
269 dcArgInt(in_self, *(DCint*) &p ); | |
270 } | |
271 | |
272 | |
273 void dc_callvm_call_ppc32_darwin(DCCallVM* in_self, DCpointer target) | |
274 { | |
275 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
276 dcCall_ppc32_darwin( |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
277 target, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
278 &self->mRegData, |
0 | 279 DC_MAX(dcVecSize(&self->mVecHead), 8*4), |
280 dcVecData(&self->mVecHead) | |
281 ); | |
282 } | |
283 | |
284 void dc_callvm_call_ppc32_sysv(DCCallVM* in_self, DCpointer target) | |
285 { | |
286 DCCallVM_ppc32* self = (DCCallVM_ppc32*) in_self; | |
287 dcCall_ppc32_sysv( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead)); | |
288 } | |
289 | |
290 void dc_callvm_call_ppc32_syscall(DCCallVM* in_self, DCpointer target) | |
291 { | |
292 DCCallVM_ppc32* self = (DCCallVM_ppc32*) in_self; | |
293 dcCall_ppc32_syscall( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead)); | |
294 } | |
295 | |
296 void dc_callvm_mode_ppc32(DCCallVM* in_self, DCint mode); | |
297 | |
298 DCCallVM_vt gVT_ppc32_darwin = | |
299 { | |
300 &dc_callvm_free_ppc32 | |
301 , &dc_callvm_reset_ppc32 | |
302 , &dc_callvm_mode_ppc32 | |
303 , &dc_callvm_argBool_ppc32 | |
304 , &dc_callvm_argChar_ppc32 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
305 , &dc_callvm_argShort_ppc32 |
0 | 306 , &dc_callvm_argInt_ppc32_darwin |
307 , &dc_callvm_argLong_ppc32 | |
308 , &dc_callvm_argLongLong_ppc32_darwin | |
309 , &dc_callvm_argFloat_ppc32_darwin | |
310 , &dc_callvm_argDouble_ppc32_darwin | |
311 , &dc_callvm_argPointer_ppc32 | |
312 , NULL /* argStruct */ | |
313 , (DCvoidvmfunc*) &dc_callvm_call_ppc32_darwin | |
314 , (DCboolvmfunc*) &dc_callvm_call_ppc32_darwin | |
315 , (DCcharvmfunc*) &dc_callvm_call_ppc32_darwin | |
316 , (DCshortvmfunc*) &dc_callvm_call_ppc32_darwin | |
317 , (DCintvmfunc*) &dc_callvm_call_ppc32_darwin | |
318 , (DClongvmfunc*) &dc_callvm_call_ppc32_darwin | |
319 , (DClonglongvmfunc*) &dc_callvm_call_ppc32_darwin | |
320 , (DCfloatvmfunc*) &dc_callvm_call_ppc32_darwin | |
321 , (DCdoublevmfunc*) &dc_callvm_call_ppc32_darwin | |
322 , (DCpointervmfunc*) &dc_callvm_call_ppc32_darwin | |
323 , NULL /* callStruct */ | |
324 }; | |
325 | |
326 DCCallVM_vt gVT_ppc32_sysv = | |
327 { | |
328 &dc_callvm_free_ppc32 | |
329 , &dc_callvm_reset_ppc32 | |
330 , &dc_callvm_mode_ppc32 | |
331 , &dc_callvm_argBool_ppc32 | |
332 , &dc_callvm_argChar_ppc32 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
333 , &dc_callvm_argShort_ppc32 |
0 | 334 , &dc_callvm_argInt_ppc32_sysv |
335 , &dc_callvm_argLong_ppc32 | |
336 , &dc_callvm_argLongLong_ppc32_sysv | |
337 , &dc_callvm_argFloat_ppc32_sysv | |
338 , &dc_callvm_argDouble_ppc32_sysv | |
339 , &dc_callvm_argPointer_ppc32 | |
340 , NULL /* argStruct */ | |
341 , (DCvoidvmfunc*) &dc_callvm_call_ppc32_sysv | |
342 , (DCboolvmfunc*) &dc_callvm_call_ppc32_sysv | |
343 , (DCcharvmfunc*) &dc_callvm_call_ppc32_sysv | |
344 , (DCshortvmfunc*) &dc_callvm_call_ppc32_sysv | |
345 , (DCintvmfunc*) &dc_callvm_call_ppc32_sysv | |
346 , (DClongvmfunc*) &dc_callvm_call_ppc32_sysv | |
347 , (DClonglongvmfunc*) &dc_callvm_call_ppc32_sysv | |
348 , (DCfloatvmfunc*) &dc_callvm_call_ppc32_sysv | |
349 , (DCdoublevmfunc*) &dc_callvm_call_ppc32_sysv | |
350 , (DCpointervmfunc*) &dc_callvm_call_ppc32_sysv | |
351 , NULL /* callStruct */ | |
352 }; | |
353 | |
354 DCCallVM_vt gVT_ppc32_syscall = | |
355 { | |
356 &dc_callvm_free_ppc32 | |
357 , &dc_callvm_reset_ppc32 | |
358 , &dc_callvm_mode_ppc32 | |
359 , &dc_callvm_argBool_ppc32 | |
360 , &dc_callvm_argChar_ppc32 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
361 , &dc_callvm_argShort_ppc32 |
0 | 362 , &dc_callvm_argInt_ppc32_sysv |
363 , &dc_callvm_argLong_ppc32 | |
364 , &dc_callvm_argLongLong_ppc32_sysv | |
365 , &dc_callvm_argFloat_ppc32_sysv | |
366 , &dc_callvm_argDouble_ppc32_sysv | |
367 , &dc_callvm_argPointer_ppc32 | |
368 , NULL /* argStruct */ | |
369 , (DCvoidvmfunc*) &dc_callvm_call_ppc32_syscall | |
370 , (DCboolvmfunc*) &dc_callvm_call_ppc32_syscall | |
371 , (DCcharvmfunc*) &dc_callvm_call_ppc32_syscall | |
372 , (DCshortvmfunc*) &dc_callvm_call_ppc32_syscall | |
373 , (DCintvmfunc*) &dc_callvm_call_ppc32_syscall | |
374 , (DClongvmfunc*) &dc_callvm_call_ppc32_syscall | |
375 , (DClonglongvmfunc*) &dc_callvm_call_ppc32_syscall | |
376 , (DCfloatvmfunc*) &dc_callvm_call_ppc32_syscall | |
377 , (DCdoublevmfunc*) &dc_callvm_call_ppc32_syscall | |
378 , (DCpointervmfunc*) &dc_callvm_call_ppc32_syscall | |
379 , NULL /* callStruct */ | |
380 }; | |
381 | |
382 | |
383 void dc_callvm_mode_ppc32(DCCallVM* in_self, DCint mode) | |
384 { | |
84 | 385 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; |
0 | 386 DCCallVM_vt* vt; |
84 | 387 |
0 | 388 switch(mode) { |
389 | |
390 #if defined(DC__ABI_Darwin) | |
391 case DC_CALL_C_DEFAULT: | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
392 case DC_CALL_C_DEFAULT_THIS: |
0 | 393 case DC_CALL_C_ELLIPSIS: |
394 case DC_CALL_C_ELLIPSIS_VARARGS: | |
395 #endif | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
396 case DC_CALL_C_PPC32_OSX: |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
397 vt = &gVT_ppc32_darwin; |
0 | 398 break; |
399 | |
400 #if defined(DC__ABI_SysV) | |
401 case DC_CALL_C_DEFAULT: | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
402 case DC_CALL_C_DEFAULT_THIS: |
0 | 403 case DC_CALL_C_ELLIPSIS: |
404 case DC_CALL_C_ELLIPSIS_VARARGS: | |
405 #endif | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
406 case DC_CALL_C_PPC32_SYSV: |
0 | 407 vt = &gVT_ppc32_sysv; |
408 break; | |
409 | |
410 case DC_CALL_SYS_DEFAULT: | |
411 case DC_CALL_SYS_PPC32: | |
412 vt = &gVT_ppc32_syscall; | |
413 break; | |
414 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
415 default: |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
416 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; |
0 | 417 return; |
418 } | |
84 | 419 |
0 | 420 dc_callvm_base_init(&self->mInterface, vt); |
421 } | |
422 | |
84 | 423 /* Public API. */ |
0 | 424 DCCallVM* dcNewCallVM(DCsize size) |
425 { | |
84 | 426 DCCallVM_ppc32* p = (DCCallVM_ppc32*)dcAllocMem(sizeof(DCCallVM_ppc32)+size); |
427 | |
428 dc_callvm_mode_ppc32((DCCallVM*)p, DC_CALL_C_DEFAULT); | |
429 | |
430 dcVecInit(&p->mVecHead, size); | |
431 dc_callvm_reset_ppc32((DCCallVM*)p); | |
432 | |
433 return (DCCallVM*)p; | |
0 | 434 } |
435 |