Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_callvm_sparc64.c @ 466:ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
for upcoming aggregate support (until now only x86 platforms allowed for
specifically selecting thiscall mode, given the different conventions on
the same platform); also added respective DC_SIGCHAR_CC_THISCALL ('*')
author | Tassilo Philipp |
---|---|
date | Wed, 02 Feb 2022 18:30:44 +0100 |
parents | ad5f9803f52f |
children | 71c884e610f0 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
178
183594497726
- renamed sparc_v9 -> sparc64 for consistency (with other platforms using 32/64 suffix instead of instrset name)
cslag
parents:
84
diff
changeset
|
5 File: dyncall/dyncall_callvm_sparc64.c |
183594497726
- renamed sparc_v9 -> sparc64 for consistency (with other platforms using 32/64 suffix instead of instrset name)
cslag
parents:
84
diff
changeset
|
6 Description: Call VM for sparc64 (v9) ABI. |
0 | 7 License: |
8 | |
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
|
9 Copyright (c) 2011-2020 Daniel Adler <dadler@uni-goettingen.de> |
0 | 10 |
11 Permission to use, copy, modify, and distribute this software for any | |
12 purpose with or without fee is hereby granted, provided that the above | |
13 copyright notice and this permission notice appear in all copies. | |
14 | |
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | |
23 */ | |
24 | |
25 | |
26 | |
178
183594497726
- renamed sparc_v9 -> sparc64 for consistency (with other platforms using 32/64 suffix instead of instrset name)
cslag
parents:
84
diff
changeset
|
27 #include "dyncall_callvm_sparc64.h" |
0 | 28 #include "dyncall_alloc.h" |
29 | |
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
|
30 |
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
|
31 void dcCall_v9(DCCallVM* vm, DCpointer target); |
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
|
32 |
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
|
33 |
0 | 34 /* Reset argument buffer. */ |
35 static void dc_callvm_reset_v9(DCCallVM* in_self) | |
36 { | |
37 DCCallVM_v9* self = (DCCallVM_v9*)in_self; | |
84 | 38 dcVecResize(&self->mVecHead, 0); |
0 | 39 } |
40 | |
41 | |
42 /* Destructor. */ | |
43 static void dc_callvm_free_v9(DCCallVM* in_self) | |
44 { | |
45 dcFreeMem(in_self); | |
46 } | |
47 | |
48 static void dc_callvm_argLongLong_v9(DCCallVM* in_self, DClonglong x) | |
49 { | |
50 DCCallVM_v9* self = (DCCallVM_v9*)in_self; | |
51 dcVecAppend(&self->mVecHead, &x, sizeof(DClonglong)); | |
52 } | |
53 | |
54 /* all integers are promoted to 64-bit. */ | |
55 static void dc_callvm_argLong_v9 (DCCallVM* in_self, DClong x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
56 static void dc_callvm_argInt_v9 (DCCallVM* in_self, DCint x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
57 static void dc_callvm_argBool_v9 (DCCallVM* in_self, DCbool x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
58 static void dc_callvm_argChar_v9 (DCCallVM* in_self, DCchar x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
59 static void dc_callvm_argShort_v9 (DCCallVM* in_self, DCshort x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
60 static void dc_callvm_argPointer_v9(DCCallVM* in_self, DCpointer x) { dc_callvm_argLongLong_v9(in_self, (DClonglong) x ); } | |
61 | |
62 static void dc_callvm_argDouble_v9(DCCallVM* in_self, DCdouble x) | |
63 { | |
64 DCCallVM_v9* self = (DCCallVM_v9*)in_self; | |
65 dcVecAppend(&self->mVecHead, &x, sizeof(DCdouble)); | |
66 } | |
67 | |
68 static void dc_callvm_argDouble_v9_ellipsis(DCCallVM* in_self, DCdouble x) | |
69 { | |
70 union { | |
71 long long l; | |
72 double d; | |
73 } u; | |
74 u.d = x; | |
75 dc_callvm_argLongLong_v9(in_self, u.l); | |
76 } | |
77 | |
78 static void dc_callvm_argFloat_v9_ellipsis(DCCallVM* in_self, DCfloat x) | |
79 { | |
80 dc_callvm_argDouble_v9_ellipsis(in_self, (DCdouble) x); | |
81 } | |
82 | |
83 static void dc_callvm_argFloat_v9(DCCallVM* in_self, DCfloat x) | |
84 { | |
85 union { | |
86 double d; | |
87 float f[2]; | |
88 } u; | |
89 u.f[1] = x; | |
90 dc_callvm_argDouble_v9(in_self, u.d); | |
91 } | |
92 | |
93 static void dc_callvm_mode_v9(DCCallVM* in_self, DCint mode); | |
94 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
95 DCCallVM_vt gVT_v9_ellipsis = |
0 | 96 { |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
97 &dc_callvm_free_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
98 &dc_callvm_reset_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
99 &dc_callvm_mode_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
100 &dc_callvm_argBool_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
101 &dc_callvm_argChar_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
102 &dc_callvm_argShort_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
103 &dc_callvm_argInt_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
104 &dc_callvm_argLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
105 &dc_callvm_argLongLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
106 &dc_callvm_argFloat_v9_ellipsis, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
107 &dc_callvm_argDouble_v9_ellipsis, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
108 &dc_callvm_argPointer_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
109 NULL /* argStruct */, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
110 (DCvoidvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
111 (DCboolvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
112 (DCcharvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
113 (DCshortvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
114 (DCintvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
115 (DClongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
116 (DClonglongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
117 (DCfloatvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
118 (DCdoublevmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
119 (DCpointervmfunc*) &dcCall_v9, |
0 | 120 NULL /* callStruct */ |
121 }; | |
122 | |
123 /* CallVM virtual table. */ | |
124 DCCallVM_vt gVT_v9 = | |
125 { | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
126 &dc_callvm_free_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
127 &dc_callvm_reset_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
128 &dc_callvm_mode_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
129 &dc_callvm_argBool_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
130 &dc_callvm_argChar_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
131 &dc_callvm_argShort_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
132 &dc_callvm_argInt_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
133 &dc_callvm_argLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
134 &dc_callvm_argLongLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
135 &dc_callvm_argFloat_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
136 &dc_callvm_argDouble_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
137 &dc_callvm_argPointer_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
138 NULL /* argStruct */, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
139 (DCvoidvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
140 (DCboolvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
141 (DCcharvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
142 (DCshortvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
143 (DCintvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
144 (DClongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
145 (DClonglongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
146 (DCfloatvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
147 (DCdoublevmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
148 (DCpointervmfunc*) &dcCall_v9, |
0 | 149 NULL /* callStruct */ |
150 }; | |
151 | |
152 /* mode: only a single mode available currently. */ | |
153 static void dc_callvm_mode_v9(DCCallVM* in_self, DCint mode) | |
154 { | |
84 | 155 DCCallVM_v9* self = (DCCallVM_v9*)in_self; |
156 DCCallVM_vt* vt; | |
157 | |
0 | 158 switch(mode) { |
159 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
|
160 case DC_CALL_C_DEFAULT_THIS: |
84 | 161 case DC_CALL_C_SPARC64: |
0 | 162 case DC_CALL_C_ELLIPSIS: |
84 | 163 vt = &gVT_v9; |
0 | 164 break; |
165 case DC_CALL_C_ELLIPSIS_VARARGS: | |
84 | 166 vt = &gVT_v9_ellipsis; |
0 | 167 break; |
168 default: | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
169 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
170 return; |
0 | 171 } |
84 | 172 dc_callvm_base_init(&self->mInterface, vt); |
0 | 173 } |
174 | |
175 /* Public API. */ | |
176 DCCallVM* dcNewCallVM(DCsize size) | |
177 { | |
84 | 178 DCCallVM_v9* p = (DCCallVM_v9*)dcAllocMem(sizeof(DCCallVM_v9)+size); |
179 | |
180 dc_callvm_mode_v9((DCCallVM*)p, DC_CALL_C_DEFAULT); | |
181 | |
182 dcVecInit(&p->mVecHead,size); | |
183 dc_callvm_reset_v9(&p->mInterface); | |
184 | |
185 return (DCCallVM*)p; | |
0 | 186 } |
187 |