Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall.h @ 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 | 0c8838766866 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall.h | |
6 Description: public header for library dyncall | |
7 License: | |
8 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
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 #ifndef DYNCALL_H | |
28 #define DYNCALL_H | |
29 | |
30 #include "dyncall_types.h" | |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
31 #include "dyncall_signature.h" |
0 | 32 |
33 #ifdef __cplusplus | |
34 extern "C" { | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
35 #endif |
0 | 36 |
37 typedef struct DCCallVM_ DCCallVM; | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
38 typedef struct DCaggr_ DCaggr; |
0 | 39 |
40 /* Supported Calling Convention Modes */ | |
41 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
42 /* default */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
43 #define DC_CALL_C_DEFAULT 0 /* C default (platform native) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
44 #define DC_CALL_C_DEFAULT_THIS 99 /* for C++ calls where first param is hidden this ptr (platform native) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
45 #define DC_CALL_C_ELLIPSIS 100 /* to be set for vararg calls' non-hidden (e.g. C++ this ptr), named arguments */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
46 #define DC_CALL_C_ELLIPSIS_VARARGS 101 /* to be set for vararg calls' non-hidden (e.g. C++ this ptr), variable arguments (in ... part) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
47 /* platform specific */ |
0 | 48 #define DC_CALL_C_X86_CDECL 1 |
49 #define DC_CALL_C_X86_WIN32_STD 2 | |
50 #define DC_CALL_C_X86_WIN32_FAST_MS 3 | |
51 #define DC_CALL_C_X86_WIN32_FAST_GNU 4 | |
52 #define DC_CALL_C_X86_WIN32_THIS_MS 5 | |
364 | 53 #define DC_CALL_C_X86_WIN32_THIS_GNU DC_CALL_C_X86_CDECL /* alias - identical to cdecl (w/ this-ptr as 1st arg) */ |
0 | 54 #define DC_CALL_C_X64_WIN64 7 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
55 #define DC_CALL_C_X64_WIN64_THIS 70 /* only needed when using aggregate by value as return type */ |
0 | 56 #define DC_CALL_C_X64_SYSV 8 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
57 #define DC_CALL_C_X64_SYSV_THIS DC_CALL_C_X64_SYSV /* alias */ |
0 | 58 #define DC_CALL_C_PPC32_DARWIN 9 |
59 #define DC_CALL_C_PPC32_OSX DC_CALL_C_PPC32_DARWIN /* alias */ | |
60 #define DC_CALL_C_ARM_ARM_EABI 10 | |
61 #define DC_CALL_C_ARM_THUMB_EABI 11 | |
62 #define DC_CALL_C_ARM_ARMHF 30 | |
63 #define DC_CALL_C_MIPS32_EABI 12 | |
64 #define DC_CALL_C_MIPS32_PSPSDK DC_CALL_C_MIPS32_EABI /* alias - deprecated. */ | |
65 #define DC_CALL_C_PPC32_SYSV 13 | |
66 #define DC_CALL_C_PPC32_LINUX DC_CALL_C_PPC32_SYSV /* alias */ | |
67 #define DC_CALL_C_ARM_ARM 14 | |
68 #define DC_CALL_C_ARM_THUMB 15 | |
69 #define DC_CALL_C_MIPS32_O32 16 | |
70 #define DC_CALL_C_MIPS64_N32 17 | |
71 #define DC_CALL_C_MIPS64_N64 18 | |
72 #define DC_CALL_C_X86_PLAN9 19 | |
73 #define DC_CALL_C_SPARC32 20 | |
74 #define DC_CALL_C_SPARC64 21 | |
75 #define DC_CALL_C_ARM64 22 | |
76 #define DC_CALL_C_PPC64 23 | |
77 #define DC_CALL_C_PPC64_LINUX DC_CALL_C_PPC64 /* alias */ | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
78 /* syscalls, default */ |
0 | 79 #define DC_CALL_SYS_DEFAULT 200 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
80 /* syscalls, platform specific */ |
0 | 81 #define DC_CALL_SYS_X86_INT80H_LINUX 201 |
82 #define DC_CALL_SYS_X86_INT80H_BSD 202 | |
339 | 83 #define DC_CALL_SYS_X64_SYSCALL_SYSV 204 |
0 | 84 #define DC_CALL_SYS_PPC32 210 |
7 | 85 #define DC_CALL_SYS_PPC64 211 |
0 | 86 |
87 /* Error codes. */ | |
88 | |
89 #define DC_ERROR_NONE 0 | |
90 #define DC_ERROR_UNSUPPORTED_MODE -1 | |
91 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
92 DC_API DCCallVM* dcNewCallVM (DCsize size); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
93 DC_API void dcFree (DCCallVM* vm); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
94 DC_API void dcReset (DCCallVM* vm); |
0 | 95 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
96 DC_API void dcMode (DCCallVM* vm, DCint mode); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
97 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
98 DC_API void dcBeginCallAggr (DCCallVM* vm, const DCaggr* ag); |
0 | 99 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
100 DC_API void dcArgBool (DCCallVM* vm, DCbool value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
101 DC_API void dcArgChar (DCCallVM* vm, DCchar value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
102 DC_API void dcArgShort (DCCallVM* vm, DCshort value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
103 DC_API void dcArgInt (DCCallVM* vm, DCint value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
104 DC_API void dcArgLong (DCCallVM* vm, DClong value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
105 DC_API void dcArgLongLong (DCCallVM* vm, DClonglong value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
106 DC_API void dcArgFloat (DCCallVM* vm, DCfloat value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
107 DC_API void dcArgDouble (DCCallVM* vm, DCdouble value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
108 DC_API void dcArgPointer (DCCallVM* vm, DCpointer value); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
109 DC_API void dcArgAggr (DCCallVM* vm, const DCaggr* ag, const void* value); |
0 | 110 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
111 DC_API void dcCallVoid (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
112 DC_API DCbool dcCallBool (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
113 DC_API DCchar dcCallChar (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
114 DC_API DCshort dcCallShort (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
115 DC_API DCint dcCallInt (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
116 DC_API DClong dcCallLong (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
117 DC_API DClonglong dcCallLongLong (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
118 DC_API DCfloat dcCallFloat (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
119 DC_API DCdouble dcCallDouble (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
120 DC_API DCpointer dcCallPointer (DCCallVM* vm, DCpointer funcptr); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
121 DC_API DCpointer dcCallAggr (DCCallVM* vm, DCpointer funcptr, const DCaggr* ag, DCpointer ret); /* retval is written to *ret, returns ret */ |
0 | 122 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
123 DC_API DCint dcGetError (DCCallVM* vm); |
0 | 124 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
125 DC_API DCaggr* dcNewAggr (DCsize maxFieldCount, DCsize size); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
126 DC_API void dcFreeAggr (DCaggr* ag); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
127 /* if type == DC_SIGCHAR_AGGREGATE, pass DCaggr* of nested struct/union in ... */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
128 DC_API void dcAggrField (DCaggr* ag, DCsigchar type, DCint offset, DCsize array_len, ...); |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
129 DC_API void dcCloseAggr (DCaggr* ag); /* to indicate end of struct definition, required */ |
0 | 130 |
131 | |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
132 /* helpers */ |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
133 |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
134 /* returns respective mode for callconv sig char (w/o checking if mode exists */ |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
135 /* on current platform), or DC_ERROR_UNSUPPORTED_MODE if char isn't a sigchar */ |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
136 DC_API DCint dcGetModeFromCCSigChar(DCsigchar sig_char); |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
137 |
0 | 138 #ifdef __cplusplus |
139 } | |
140 #endif | |
141 | |
142 #endif /* DYNCALL_H */ | |
143 |