Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_callvm_sparc64.c @ 533:71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
* integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv)
* windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.)
* see Changelog for details
- new calling convention modes for thiscalls (platform agnostic, was specific before)
* new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL)
- dcCallF(), dcVCallF(), dcArgF() and dcVArgF():
* added support for aggregates-by-value (wasn't part of patch)
* change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change)
- added macros to feature test implementation for aggregate-by-value and syscall support
- changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order
- doc:
* man page updates to describe aggregate interface
* manual overview changes to highlight platforms with aggregate-by-value support
- test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author | Tassilo Philipp |
---|---|
date | Thu, 21 Apr 2022 13:35:47 +0200 |
parents | ddfb9577a00e |
children |
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, |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
109 NULL /* argAggr */, |
466
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, |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
120 NULL /* callAggr */, |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
121 NULL /* beginAggr */ |
0 | 122 }; |
123 | |
124 /* CallVM virtual table. */ | |
125 DCCallVM_vt gVT_v9 = | |
126 { | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
127 &dc_callvm_free_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
128 &dc_callvm_reset_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
129 &dc_callvm_mode_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
130 &dc_callvm_argBool_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
131 &dc_callvm_argChar_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
132 &dc_callvm_argShort_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
133 &dc_callvm_argInt_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
134 &dc_callvm_argLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
135 &dc_callvm_argLongLong_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
136 &dc_callvm_argFloat_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
137 &dc_callvm_argDouble_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
138 &dc_callvm_argPointer_v9, |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
139 NULL /* argAggr */, |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
140 (DCvoidvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
141 (DCboolvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
142 (DCcharvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
143 (DCshortvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
144 (DCintvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
145 (DClongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
146 (DClonglongvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
147 (DCfloatvmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
148 (DCdoublevmfunc*) &dcCall_v9, |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
149 (DCpointervmfunc*) &dcCall_v9, |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
150 NULL /* callAggr */, |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
151 NULL /* beginAggr */ |
0 | 152 }; |
153 | |
154 /* mode: only a single mode available currently. */ | |
155 static void dc_callvm_mode_v9(DCCallVM* in_self, DCint mode) | |
156 { | |
84 | 157 DCCallVM_v9* self = (DCCallVM_v9*)in_self; |
158 DCCallVM_vt* vt; | |
159 | |
0 | 160 switch(mode) { |
161 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
|
162 case DC_CALL_C_DEFAULT_THIS: |
84 | 163 case DC_CALL_C_SPARC64: |
0 | 164 case DC_CALL_C_ELLIPSIS: |
84 | 165 vt = &gVT_v9; |
0 | 166 break; |
167 case DC_CALL_C_ELLIPSIS_VARARGS: | |
84 | 168 vt = &gVT_v9_ellipsis; |
0 | 169 break; |
170 default: | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
171 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
|
172 return; |
0 | 173 } |
84 | 174 dc_callvm_base_init(&self->mInterface, vt); |
0 | 175 } |
176 | |
177 /* Public API. */ | |
178 DCCallVM* dcNewCallVM(DCsize size) | |
179 { | |
84 | 180 DCCallVM_v9* p = (DCCallVM_v9*)dcAllocMem(sizeof(DCCallVM_v9)+size); |
181 | |
182 dc_callvm_mode_v9((DCCallVM*)p, DC_CALL_C_DEFAULT); | |
183 | |
184 dcVecInit(&p->mVecHead,size); | |
185 dc_callvm_reset_v9(&p->mInterface); | |
186 | |
187 return (DCCallVM*)p; | |
0 | 188 } |
189 |