Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_thunk.h @ 0:3e629dc19168
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:24:28 +0100 |
parents | |
children | 1ce60358fbad |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e629dc19168 |
---|---|
1 /* | |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_thunk.h | |
6 Description: Thunk - Interface | |
7 License: | |
8 | |
9 Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>, | |
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_THUNK_H | |
28 #define DYNCALL_THUNK_H | |
29 | |
30 /** | |
31 ** dyncall thunks | |
32 ** | |
33 ** thunks are small-size hybrid code/data objects, created at run-time to | |
34 ** be used as function pointers with associated data and entry functions. | |
35 ** | |
36 ** The header contains code, that does load its address into a designated scratch | |
37 ** register and will jump to a thunk function. | |
38 ** | |
39 ** Thunk entry procedures are compiled functions, that are called as a result of | |
40 ** a thunk function. | |
41 ** There is one thunk entry currently for supporting callbacks. | |
42 ** | |
43 ** Thunk context register ( ::= an available scratch register in the calling convention): | |
44 ** | |
45 ** x86: eax | |
46 ** x64: rax | |
47 ** ppc: r2 | |
48 ** arm: r12 | |
49 ** arm64: x9 | |
50 ** | |
51 **/ | |
52 | |
53 #include "dyncall_macros.h" | |
54 | |
55 typedef struct DCThunk_ DCThunk; | |
56 | |
57 #ifdef __cplusplus | |
58 extern "C" { | |
59 #endif | |
60 | |
61 void dcbInitThunk(DCThunk* p, void (*entry)()); | |
62 | |
63 #if defined(DC__Arch_Intel_x86) | |
64 #include "dyncall_thunk_x86.h" | |
65 #elif defined (DC__Arch_AMD64) | |
66 #include "dyncall_thunk_x64.h" | |
67 #elif defined (DC__Arch_PPC32) | |
68 #include "dyncall_thunk_ppc32.h" | |
69 #elif defined (DC__Arch_PPC64) | |
70 #include "dyncall_thunk_ppc64.h" | |
71 #elif defined (DC__Arch_ARM_ARM) | |
72 #include "dyncall_thunk_arm32_arm.h" | |
73 #elif defined (DC__Arch_ARM_THUMB) | |
74 #include "dyncall_thunk_arm32_thumb.h" | |
75 #elif defined (DC__Arch_MIPS) | |
76 #include "dyncall_thunk_mips.h" | |
77 #elif defined (DC__Arch_Sparc) | |
78 #include "dyncall_thunk_sparc32.h" | |
79 #elif defined (DC__Arch_Sparcv9) | |
80 #include "dyncall_thunk_sparc64.h" | |
81 #elif defined (DC__Arch_ARM64) | |
82 #include "dyncall_thunk_arm64.h" | |
83 #endif | |
84 | |
85 #ifdef __cplusplus | |
86 } | |
87 #endif | |
88 | |
89 | |
90 #endif /* DYNCALL_THUNK_H */ |