Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_callvm_ppc32.c @ 663:127b569978cc default tip
- another tweak handling clang trying to be too smart (see last commit)
author | Tassilo Philipp |
---|---|
date | Sun, 24 Mar 2024 13:52:44 +0100 |
parents | 71c884e610f0 |
children |
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 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
312 , NULL /* argAggr */ |
0 | 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 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
323 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
324 , NULL /* beginAggr */ |
0 | 325 }; |
326 | |
327 DCCallVM_vt gVT_ppc32_sysv = | |
328 { | |
329 &dc_callvm_free_ppc32 | |
330 , &dc_callvm_reset_ppc32 | |
331 , &dc_callvm_mode_ppc32 | |
332 , &dc_callvm_argBool_ppc32 | |
333 , &dc_callvm_argChar_ppc32 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
334 , &dc_callvm_argShort_ppc32 |
0 | 335 , &dc_callvm_argInt_ppc32_sysv |
336 , &dc_callvm_argLong_ppc32 | |
337 , &dc_callvm_argLongLong_ppc32_sysv | |
338 , &dc_callvm_argFloat_ppc32_sysv | |
339 , &dc_callvm_argDouble_ppc32_sysv | |
340 , &dc_callvm_argPointer_ppc32 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
341 , NULL /* argAggr */ |
0 | 342 , (DCvoidvmfunc*) &dc_callvm_call_ppc32_sysv |
343 , (DCboolvmfunc*) &dc_callvm_call_ppc32_sysv | |
344 , (DCcharvmfunc*) &dc_callvm_call_ppc32_sysv | |
345 , (DCshortvmfunc*) &dc_callvm_call_ppc32_sysv | |
346 , (DCintvmfunc*) &dc_callvm_call_ppc32_sysv | |
347 , (DClongvmfunc*) &dc_callvm_call_ppc32_sysv | |
348 , (DClonglongvmfunc*) &dc_callvm_call_ppc32_sysv | |
349 , (DCfloatvmfunc*) &dc_callvm_call_ppc32_sysv | |
350 , (DCdoublevmfunc*) &dc_callvm_call_ppc32_sysv | |
351 , (DCpointervmfunc*) &dc_callvm_call_ppc32_sysv | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
352 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
353 , NULL /* beginAggr */ |
0 | 354 }; |
355 | |
356 DCCallVM_vt gVT_ppc32_syscall = | |
357 { | |
358 &dc_callvm_free_ppc32 | |
359 , &dc_callvm_reset_ppc32 | |
360 , &dc_callvm_mode_ppc32 | |
361 , &dc_callvm_argBool_ppc32 | |
362 , &dc_callvm_argChar_ppc32 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
363 , &dc_callvm_argShort_ppc32 |
0 | 364 , &dc_callvm_argInt_ppc32_sysv |
365 , &dc_callvm_argLong_ppc32 | |
366 , &dc_callvm_argLongLong_ppc32_sysv | |
367 , &dc_callvm_argFloat_ppc32_sysv | |
368 , &dc_callvm_argDouble_ppc32_sysv | |
369 , &dc_callvm_argPointer_ppc32 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
370 , NULL /* argAggr */ |
0 | 371 , (DCvoidvmfunc*) &dc_callvm_call_ppc32_syscall |
372 , (DCboolvmfunc*) &dc_callvm_call_ppc32_syscall | |
373 , (DCcharvmfunc*) &dc_callvm_call_ppc32_syscall | |
374 , (DCshortvmfunc*) &dc_callvm_call_ppc32_syscall | |
375 , (DCintvmfunc*) &dc_callvm_call_ppc32_syscall | |
376 , (DClongvmfunc*) &dc_callvm_call_ppc32_syscall | |
377 , (DClonglongvmfunc*) &dc_callvm_call_ppc32_syscall | |
378 , (DCfloatvmfunc*) &dc_callvm_call_ppc32_syscall | |
379 , (DCdoublevmfunc*) &dc_callvm_call_ppc32_syscall | |
380 , (DCpointervmfunc*) &dc_callvm_call_ppc32_syscall | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
381 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
382 , NULL /* beginAggr */ |
0 | 383 }; |
384 | |
385 | |
386 void dc_callvm_mode_ppc32(DCCallVM* in_self, DCint mode) | |
387 { | |
84 | 388 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; |
0 | 389 DCCallVM_vt* vt; |
84 | 390 |
0 | 391 switch(mode) { |
392 | |
393 #if defined(DC__ABI_Darwin) | |
394 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
|
395 case DC_CALL_C_DEFAULT_THIS: |
0 | 396 case DC_CALL_C_ELLIPSIS: |
397 case DC_CALL_C_ELLIPSIS_VARARGS: | |
398 #endif | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
399 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
|
400 vt = &gVT_ppc32_darwin; |
0 | 401 break; |
402 | |
403 #if defined(DC__ABI_SysV) | |
404 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
|
405 case DC_CALL_C_DEFAULT_THIS: |
0 | 406 case DC_CALL_C_ELLIPSIS: |
407 case DC_CALL_C_ELLIPSIS_VARARGS: | |
408 #endif | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
409 case DC_CALL_C_PPC32_SYSV: |
0 | 410 vt = &gVT_ppc32_sysv; |
411 break; | |
412 | |
413 case DC_CALL_SYS_DEFAULT: | |
414 case DC_CALL_SYS_PPC32: | |
415 vt = &gVT_ppc32_syscall; | |
416 break; | |
417 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
418 default: |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
419 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; |
0 | 420 return; |
421 } | |
84 | 422 |
0 | 423 dc_callvm_base_init(&self->mInterface, vt); |
424 } | |
425 | |
84 | 426 /* Public API. */ |
0 | 427 DCCallVM* dcNewCallVM(DCsize size) |
428 { | |
84 | 429 DCCallVM_ppc32* p = (DCCallVM_ppc32*)dcAllocMem(sizeof(DCCallVM_ppc32)+size); |
430 | |
431 dc_callvm_mode_ppc32((DCCallVM*)p, DC_CALL_C_DEFAULT); | |
432 | |
433 dcVecInit(&p->mVecHead, size); | |
434 dc_callvm_reset_ppc32((DCCallVM*)p); | |
435 | |
436 return (DCCallVM*)p; | |
0 | 437 } |
438 |