Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall.h @ 364:3bdd326dc269
- Todo entries
- some clarifications in code about GNU thiscalls (which are effectively idential to cdecl calls)
* took away own mode identifier, as aliasing to cdecl now
- cleanups
author | Tassilo Philipp |
---|---|
date | Tue, 14 Apr 2020 19:35:30 +0200 |
parents | 78dfa2f9783a |
children | ddfb9577a00e |
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 | |
339 | 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 dyncall C API | |
30 | |
31 REVISION | |
7 | 32 2015/07/08 added SYS_PPC64 system call |
0 | 33 2015/01/16 added SYS_PPC32 system call |
34 2007/12/11 initial | |
35 | |
36 */ | |
37 | |
38 #ifndef DYNCALL_H | |
39 #define DYNCALL_H | |
40 | |
41 #include "dyncall_types.h" | |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
42 #include "dyncall_signature.h" |
0 | 43 |
44 #ifdef __cplusplus | |
45 extern "C" { | |
46 #endif | |
47 | |
48 typedef struct DCCallVM_ DCCallVM; | |
49 typedef struct DCstruct_ DCstruct; | |
50 | |
51 /* Supported Calling Convention Modes */ | |
52 | |
53 #define DC_CALL_C_DEFAULT 0 | |
54 #define DC_CALL_C_ELLIPSIS 100 | |
55 #define DC_CALL_C_ELLIPSIS_VARARGS 101 | |
56 #define DC_CALL_C_X86_CDECL 1 | |
57 #define DC_CALL_C_X86_WIN32_STD 2 | |
58 #define DC_CALL_C_X86_WIN32_FAST_MS 3 | |
59 #define DC_CALL_C_X86_WIN32_FAST_GNU 4 | |
60 #define DC_CALL_C_X86_WIN32_THIS_MS 5 | |
364 | 61 #define DC_CALL_C_X86_WIN32_THIS_GNU DC_CALL_C_X86_CDECL /* alias - identical to cdecl (w/ this-ptr as 1st arg) */ |
0 | 62 #define DC_CALL_C_X64_WIN64 7 |
63 #define DC_CALL_C_X64_SYSV 8 | |
64 #define DC_CALL_C_PPC32_DARWIN 9 | |
65 #define DC_CALL_C_PPC32_OSX DC_CALL_C_PPC32_DARWIN /* alias */ | |
66 #define DC_CALL_C_ARM_ARM_EABI 10 | |
67 #define DC_CALL_C_ARM_THUMB_EABI 11 | |
68 #define DC_CALL_C_ARM_ARMHF 30 | |
69 #define DC_CALL_C_MIPS32_EABI 12 | |
70 #define DC_CALL_C_MIPS32_PSPSDK DC_CALL_C_MIPS32_EABI /* alias - deprecated. */ | |
71 #define DC_CALL_C_PPC32_SYSV 13 | |
72 #define DC_CALL_C_PPC32_LINUX DC_CALL_C_PPC32_SYSV /* alias */ | |
73 #define DC_CALL_C_ARM_ARM 14 | |
74 #define DC_CALL_C_ARM_THUMB 15 | |
75 #define DC_CALL_C_MIPS32_O32 16 | |
76 #define DC_CALL_C_MIPS64_N32 17 | |
77 #define DC_CALL_C_MIPS64_N64 18 | |
78 #define DC_CALL_C_X86_PLAN9 19 | |
79 #define DC_CALL_C_SPARC32 20 | |
80 #define DC_CALL_C_SPARC64 21 | |
81 #define DC_CALL_C_ARM64 22 | |
82 #define DC_CALL_C_PPC64 23 | |
83 #define DC_CALL_C_PPC64_LINUX DC_CALL_C_PPC64 /* alias */ | |
84 #define DC_CALL_SYS_DEFAULT 200 | |
85 #define DC_CALL_SYS_X86_INT80H_LINUX 201 | |
86 #define DC_CALL_SYS_X86_INT80H_BSD 202 | |
339 | 87 #define DC_CALL_SYS_X64_SYSCALL_SYSV 204 |
0 | 88 #define DC_CALL_SYS_PPC32 210 |
7 | 89 #define DC_CALL_SYS_PPC64 211 |
0 | 90 |
91 /* Error codes. */ | |
92 | |
93 #define DC_ERROR_NONE 0 | |
94 #define DC_ERROR_UNSUPPORTED_MODE -1 | |
95 | |
96 DC_API DCCallVM* dcNewCallVM (DCsize size); | |
97 DC_API void dcFree (DCCallVM* vm); | |
98 DC_API void dcReset (DCCallVM* vm); | |
99 | |
100 DC_API void dcMode (DCCallVM* vm, DCint mode); | |
101 | |
102 DC_API void dcArgBool (DCCallVM* vm, DCbool value); | |
103 DC_API void dcArgChar (DCCallVM* vm, DCchar value); | |
104 DC_API void dcArgShort (DCCallVM* vm, DCshort value); | |
105 DC_API void dcArgInt (DCCallVM* vm, DCint value); | |
106 DC_API void dcArgLong (DCCallVM* vm, DClong value); | |
107 DC_API void dcArgLongLong (DCCallVM* vm, DClonglong value); | |
108 DC_API void dcArgFloat (DCCallVM* vm, DCfloat value); | |
109 DC_API void dcArgDouble (DCCallVM* vm, DCdouble value); | |
110 DC_API void dcArgPointer (DCCallVM* vm, DCpointer value); | |
111 DC_API void dcArgStruct (DCCallVM* vm, DCstruct* s, DCpointer value); | |
112 | |
113 DC_API void dcCallVoid (DCCallVM* vm, DCpointer funcptr); | |
114 DC_API DCbool dcCallBool (DCCallVM* vm, DCpointer funcptr); | |
115 DC_API DCchar dcCallChar (DCCallVM* vm, DCpointer funcptr); | |
116 DC_API DCshort dcCallShort (DCCallVM* vm, DCpointer funcptr); | |
117 DC_API DCint dcCallInt (DCCallVM* vm, DCpointer funcptr); | |
118 DC_API DClong dcCallLong (DCCallVM* vm, DCpointer funcptr); | |
119 DC_API DClonglong dcCallLongLong (DCCallVM* vm, DCpointer funcptr); | |
120 DC_API DCfloat dcCallFloat (DCCallVM* vm, DCpointer funcptr); | |
121 DC_API DCdouble dcCallDouble (DCCallVM* vm, DCpointer funcptr); | |
122 DC_API DCpointer dcCallPointer (DCCallVM* vm, DCpointer funcptr); | |
123 DC_API void dcCallStruct (DCCallVM* vm, DCpointer funcptr, DCstruct* s, DCpointer returnValue); | |
124 | |
125 DC_API DCint dcGetError (DCCallVM* vm); | |
126 | |
127 #define DEFAULT_ALIGNMENT 0 | |
128 DC_API DCstruct* dcNewStruct (DCsize fieldCount, DCint alignment); | |
129 DC_API void dcStructField (DCstruct* s, DCint type, DCint alignment, DCsize arrayLength); | |
130 DC_API void dcSubStruct (DCstruct* s, DCsize fieldCount, DCint alignment, DCsize arrayLength); | |
131 /* Each dcNewStruct or dcSubStruct call must be paired with a dcCloseStruct. */ | |
132 DC_API void dcCloseStruct (DCstruct* s); | |
133 DC_API DCsize dcStructSize (DCstruct* s); | |
134 DC_API DCsize dcStructAlignment(DCstruct* s); | |
135 DC_API void dcFreeStruct (DCstruct* s); | |
136 | |
137 DC_API DCstruct* dcDefineStruct (const char* signature); | |
138 | |
139 | |
362
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
140 /* helpers */ |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
141 |
78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents:
339
diff
changeset
|
142 /* 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
|
143 /* 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
|
144 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
|
145 |
0 | 146 #ifdef __cplusplus |
147 } | |
148 #endif | |
149 | |
150 #endif /* DYNCALL_H */ | |
151 |