Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall.h @ 529:fe694c7677b4
- mips eabi doc disas examples
author | Tassilo Philipp |
---|---|
date | Thu, 14 Apr 2022 21:18:02 +0200 |
parents | ddfb9577a00e |
children | 71c884e610f0 |
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 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
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 #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; | |
38 typedef struct DCstruct_ DCstruct; | |
39 | |
40 /* Supported Calling Convention Modes */ | |
41 | |
42 #define DC_CALL_C_DEFAULT 0 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
43 #define DC_CALL_C_DEFAULT_THIS 99 |
0 | 44 #define DC_CALL_C_ELLIPSIS 100 |
45 #define DC_CALL_C_ELLIPSIS_VARARGS 101 | |
46 #define DC_CALL_C_X86_CDECL 1 | |
47 #define DC_CALL_C_X86_WIN32_STD 2 | |
48 #define DC_CALL_C_X86_WIN32_FAST_MS 3 | |
49 #define DC_CALL_C_X86_WIN32_FAST_GNU 4 | |
50 #define DC_CALL_C_X86_WIN32_THIS_MS 5 | |
364 | 51 #define DC_CALL_C_X86_WIN32_THIS_GNU DC_CALL_C_X86_CDECL /* alias - identical to cdecl (w/ this-ptr as 1st arg) */ |
0 | 52 #define DC_CALL_C_X64_WIN64 7 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
53 #define DC_CALL_C_X64_WIN64_THIS 70 /* only needed when using aggregate by value as return type @@@STRUCT implement */ |
0 | 54 #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
|
55 #define DC_CALL_C_X64_SYSV_THIS DC_CALL_C_X64_SYSV /* alias */ |
0 | 56 #define DC_CALL_C_PPC32_DARWIN 9 |
57 #define DC_CALL_C_PPC32_OSX DC_CALL_C_PPC32_DARWIN /* alias */ | |
58 #define DC_CALL_C_ARM_ARM_EABI 10 | |
59 #define DC_CALL_C_ARM_THUMB_EABI 11 | |
60 #define DC_CALL_C_ARM_ARMHF 30 | |
61 #define DC_CALL_C_MIPS32_EABI 12 | |
62 #define DC_CALL_C_MIPS32_PSPSDK DC_CALL_C_MIPS32_EABI /* alias - deprecated. */ | |
63 #define DC_CALL_C_PPC32_SYSV 13 | |
64 #define DC_CALL_C_PPC32_LINUX DC_CALL_C_PPC32_SYSV /* alias */ | |
65 #define DC_CALL_C_ARM_ARM 14 | |
66 #define DC_CALL_C_ARM_THUMB 15 | |
67 #define DC_CALL_C_MIPS32_O32 16 | |
68 #define DC_CALL_C_MIPS64_N32 17 | |
69 #define DC_CALL_C_MIPS64_N64 18 | |
70 #define DC_CALL_C_X86_PLAN9 19 | |
71 #define DC_CALL_C_SPARC32 20 | |
72 #define DC_CALL_C_SPARC64 21 | |
73 #define DC_CALL_C_ARM64 22 | |
74 #define DC_CALL_C_PPC64 23 | |
75 #define DC_CALL_C_PPC64_LINUX DC_CALL_C_PPC64 /* alias */ | |
76 #define DC_CALL_SYS_DEFAULT 200 | |
77 #define DC_CALL_SYS_X86_INT80H_LINUX 201 | |
78 #define DC_CALL_SYS_X86_INT80H_BSD 202 | |
339 | 79 #define DC_CALL_SYS_X64_SYSCALL_SYSV 204 |
0 | 80 #define DC_CALL_SYS_PPC32 210 |
7 | 81 #define DC_CALL_SYS_PPC64 211 |
0 | 82 |
83 /* Error codes. */ | |
84 | |
85 #define DC_ERROR_NONE 0 | |
86 #define DC_ERROR_UNSUPPORTED_MODE -1 | |
87 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
88 DC_API DCCallVM* dcNewCallVM (DCsize size); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
89 DC_API void dcFree (DCCallVM* vm); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
90 DC_API void dcReset (DCCallVM* vm); |
0 | 91 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
92 DC_API void dcMode (DCCallVM* vm, DCint mode); |
0 | 93 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
94 DC_API void dcArgBool (DCCallVM* vm, DCbool value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
95 DC_API void dcArgChar (DCCallVM* vm, DCchar value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
96 DC_API void dcArgShort (DCCallVM* vm, DCshort value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
97 DC_API void dcArgInt (DCCallVM* vm, DCint value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
98 DC_API void dcArgLong (DCCallVM* vm, DClong value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
99 DC_API void dcArgLongLong (DCCallVM* vm, DClonglong value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
100 DC_API void dcArgFloat (DCCallVM* vm, DCfloat value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
101 DC_API void dcArgDouble (DCCallVM* vm, DCdouble value); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
102 DC_API void dcArgPointer (DCCallVM* vm, DCpointer value); |
0 | 103 DC_API void dcArgStruct (DCCallVM* vm, DCstruct* s, DCpointer value); |
104 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
105 DC_API void dcCallVoid (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
106 DC_API DCbool dcCallBool (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
107 DC_API DCchar dcCallChar (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
108 DC_API DCshort dcCallShort (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
109 DC_API DCint dcCallInt (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
110 DC_API DClong dcCallLong (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
111 DC_API DClonglong dcCallLongLong (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
112 DC_API DCfloat dcCallFloat (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
113 DC_API DCdouble dcCallDouble (DCCallVM* vm, DCpointer funcptr); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
114 DC_API DCpointer dcCallPointer (DCCallVM* vm, DCpointer funcptr); |
0 | 115 DC_API void dcCallStruct (DCCallVM* vm, DCpointer funcptr, DCstruct* s, DCpointer returnValue); |
116 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
117 DC_API DCint dcGetError (DCCallVM* vm); |
0 | 118 |
119 #define DEFAULT_ALIGNMENT 0 | |
120 DC_API DCstruct* dcNewStruct (DCsize fieldCount, DCint alignment); | |
121 DC_API void dcStructField (DCstruct* s, DCint type, DCint alignment, DCsize arrayLength); | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
122 DC_API void dcSubStruct (DCstruct* s, DCsize fieldCount, DCint alignment, DCsize arrayLength); |
0 | 123 /* Each dcNewStruct or dcSubStruct call must be paired with a dcCloseStruct. */ |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
124 DC_API void dcCloseStruct (DCstruct* s); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
125 DC_API DCsize dcStructSize (DCstruct* s); |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
364
diff
changeset
|
126 DC_API DCsize dcStructAlignment(DCstruct* s); |
0 | 127 DC_API void dcFreeStruct (DCstruct* s); |
128 | |
129 DC_API DCstruct* dcDefineStruct (const char* signature); | |
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 |