1 | /* -----------------------------------------------------------------*-C-*- |
---|
2 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
3 | ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. |
---|
4 | Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc |
---|
5 | Target configuration macros for PowerPC. |
---|
6 | #else |
---|
7 | ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc. |
---|
8 | Copyright (C) 2008 Free Software Foundation, Inc. |
---|
9 | |
---|
10 | Target configuration macros for x86 and x86-64. |
---|
11 | #endif |
---|
12 | |
---|
13 | Permission is hereby granted, free of charge, to any person obtaining |
---|
14 | a copy of this software and associated documentation files (the |
---|
15 | ``Software''), to deal in the Software without restriction, including |
---|
16 | without limitation the rights to use, copy, modify, merge, publish, |
---|
17 | distribute, sublicense, and/or sell copies of the Software, and to |
---|
18 | permit persons to whom the Software is furnished to do so, subject to |
---|
19 | the following conditions: |
---|
20 | |
---|
21 | The above copyright notice and this permission notice shall be included |
---|
22 | in all copies or substantial portions of the Software. |
---|
23 | |
---|
24 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, |
---|
25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
---|
28 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
---|
29 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
31 | DEALINGS IN THE SOFTWARE. |
---|
32 | |
---|
33 | ----------------------------------------------------------------------- */ |
---|
34 | |
---|
35 | #ifndef LIBFFI_TARGET_H |
---|
36 | #define LIBFFI_TARGET_H |
---|
37 | |
---|
38 | /* ---- System specific configurations ----------------------------------- */ |
---|
39 | |
---|
40 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
41 | #if defined (POWERPC) && defined (__powerpc64__) /* linux64 */ |
---|
42 | #ifndef POWERPC64 |
---|
43 | #define POWERPC64 |
---|
44 | #endif |
---|
45 | #elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */ |
---|
46 | #ifndef POWERPC64 |
---|
47 | #define POWERPC64 |
---|
48 | #endif |
---|
49 | #ifndef POWERPC_DARWIN64 |
---|
50 | #define POWERPC_DARWIN64 |
---|
51 | #endif |
---|
52 | #elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */ |
---|
53 | #ifndef POWERPC64 |
---|
54 | #define POWERPC64 |
---|
55 | #else |
---|
56 | /* For code common to all platforms on x86 and x86_64. */ |
---|
57 | #define X86_ANY |
---|
58 | |
---|
59 | #if defined (X86_64) && defined (__i386__) |
---|
60 | #undef X86_64 |
---|
61 | #define X86 |
---|
62 | #endif |
---|
63 | #endif |
---|
64 | #if defined (__i386__) || defined(__x86_64__) |
---|
65 | |
---|
66 | #ifdef X86_WIN64 |
---|
67 | #define FFI_SIZEOF_ARG 8 |
---|
68 | #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ |
---|
69 | #endif |
---|
70 | #endif |
---|
71 | |
---|
72 | #if defined (__i386__) || defined(__x86_64__) |
---|
73 | /* ---- Generic type definitions ----------------------------------------- */ |
---|
74 | |
---|
75 | #endif |
---|
76 | #ifndef LIBFFI_ASM |
---|
77 | #if defined (__i386__) || defined(__x86_64__) |
---|
78 | #ifdef X86_WIN64 |
---|
79 | #ifdef _MSC_VER |
---|
80 | typedef unsigned __int64 ffi_arg; |
---|
81 | typedef __int64 ffi_sarg; |
---|
82 | #else |
---|
83 | typedef unsigned long long ffi_arg; |
---|
84 | typedef long long ffi_sarg; |
---|
85 | #endif |
---|
86 | #else |
---|
87 | #endif |
---|
88 | typedef unsigned long ffi_arg; |
---|
89 | typedef signed long ffi_sarg; |
---|
90 | #if defined (__i386__) || defined(__x86_64__) |
---|
91 | #endif |
---|
92 | #endif |
---|
93 | |
---|
94 | typedef enum ffi_abi { |
---|
95 | FFI_FIRST_ABI = 0, |
---|
96 | |
---|
97 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
98 | #ifdef POWERPC |
---|
99 | #else |
---|
100 | /* ---- Intel x86 Win32 ---------- */ |
---|
101 | #ifdef X86_WIN32 |
---|
102 | #endif |
---|
103 | FFI_SYSV, |
---|
104 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
105 | FFI_GCC_SYSV, |
---|
106 | FFI_LINUX64, |
---|
107 | FFI_LINUX, |
---|
108 | FFI_LINUX_SOFT_FLOAT, |
---|
109 | # ifdef POWERPC64 |
---|
110 | FFI_DEFAULT_ABI = FFI_LINUX64, |
---|
111 | # else |
---|
112 | # if (!defined(__NO_FPRS__) && (__LDBL_MANT_DIG__ == 106)) |
---|
113 | FFI_DEFAULT_ABI = FFI_LINUX, |
---|
114 | # else |
---|
115 | # ifdef __NO_FPRS__ |
---|
116 | FFI_DEFAULT_ABI = FFI_LINUX_SOFT_FLOAT, |
---|
117 | # else |
---|
118 | FFI_DEFAULT_ABI = FFI_GCC_SYSV, |
---|
119 | # endif |
---|
120 | # endif |
---|
121 | # endif |
---|
122 | #endif |
---|
123 | |
---|
124 | #ifdef POWERPC_AIX |
---|
125 | FFI_AIX, |
---|
126 | FFI_DARWIN, |
---|
127 | FFI_DEFAULT_ABI = FFI_AIX, |
---|
128 | #endif |
---|
129 | #else |
---|
130 | FFI_STDCALL, |
---|
131 | FFI_LAST_ABI, |
---|
132 | /* TODO: Add fastcall support for the sake of completeness */ |
---|
133 | FFI_DEFAULT_ABI = FFI_SYSV |
---|
134 | #endif |
---|
135 | |
---|
136 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
137 | #ifdef POWERPC_DARWIN |
---|
138 | FFI_AIX, |
---|
139 | FFI_DARWIN, |
---|
140 | FFI_DEFAULT_ABI = FFI_DARWIN, |
---|
141 | #endif |
---|
142 | #else |
---|
143 | #elif defined(X86_WIN64) |
---|
144 | FFI_WIN64, |
---|
145 | FFI_LAST_ABI, |
---|
146 | FFI_DEFAULT_ABI = FFI_WIN64 |
---|
147 | #endif |
---|
148 | |
---|
149 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
150 | #ifdef POWERPC_FREEBSD |
---|
151 | #else |
---|
152 | #else |
---|
153 | /* ---- Intel x86 and AMD x86-64 - */ |
---|
154 | #endif |
---|
155 | FFI_SYSV, |
---|
156 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
157 | FFI_GCC_SYSV, |
---|
158 | FFI_LINUX64, |
---|
159 | FFI_LINUX, |
---|
160 | FFI_LINUX_SOFT_FLOAT, |
---|
161 | FFI_DEFAULT_ABI = FFI_SYSV, |
---|
162 | #else |
---|
163 | FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ |
---|
164 | FFI_LAST_ABI, |
---|
165 | #if defined(__i386__) || defined(__i386) |
---|
166 | FFI_DEFAULT_ABI = FFI_SYSV |
---|
167 | #else |
---|
168 | FFI_DEFAULT_ABI = FFI_UNIX64 |
---|
169 | #endif |
---|
170 | #endif |
---|
171 | #endif |
---|
172 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
173 | |
---|
174 | FFI_LAST_ABI |
---|
175 | #endif |
---|
176 | } ffi_abi; |
---|
177 | #endif |
---|
178 | |
---|
179 | /* ---- Definitions for closures ----------------------------------------- */ |
---|
180 | |
---|
181 | #define FFI_CLOSURES 1 |
---|
182 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
183 | #define FFI_NATIVE_RAW_API 0 |
---|
184 | |
---|
185 | /* For additional types like the below, take care about the order in |
---|
186 | ppc_closures.S. They must follow after the FFI_TYPE_LAST. */ |
---|
187 | |
---|
188 | /* Needed for soft-float long-double-128 support. */ |
---|
189 | #define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1) |
---|
190 | |
---|
191 | /* Needed for FFI_SYSV small structure returns. |
---|
192 | We use two flag bits, (FLAG_SYSV_SMST_R3, FLAG_SYSV_SMST_R4) which are |
---|
193 | defined in ffi.c, to determine the exact return type and its size. */ |
---|
194 | #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2) |
---|
195 | #else |
---|
196 | #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) |
---|
197 | #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) |
---|
198 | #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) |
---|
199 | #endif |
---|
200 | |
---|
201 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
202 | #if defined(POWERPC64) || defined(POWERPC_AIX) |
---|
203 | # if defined(POWERPC_DARWIN64) |
---|
204 | # define FFI_TRAMPOLINE_SIZE 48 |
---|
205 | # else |
---|
206 | #else |
---|
207 | #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) |
---|
208 | #endif |
---|
209 | # define FFI_TRAMPOLINE_SIZE 24 |
---|
210 | #if defined (__i386__) || defined(__x86_64__) |
---|
211 | #define FFI_NATIVE_RAW_API 0 |
---|
212 | #else |
---|
213 | #ifdef X86_WIN32 |
---|
214 | #define FFI_TRAMPOLINE_SIZE 13 |
---|
215 | #else |
---|
216 | #ifdef X86_WIN64 |
---|
217 | #define FFI_TRAMPOLINE_SIZE 29 |
---|
218 | #define FFI_NATIVE_RAW_API 0 |
---|
219 | #define FFI_NO_RAW_API 1 |
---|
220 | #else |
---|
221 | #define FFI_TRAMPOLINE_SIZE 10 |
---|
222 | #endif |
---|
223 | # endif |
---|
224 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
225 | #else /* POWERPC || POWERPC_AIX */ |
---|
226 | # define FFI_TRAMPOLINE_SIZE 40 |
---|
227 | #endif |
---|
228 | #endif |
---|
229 | #if (defined(__ppc__) || defined(__ppc64__)) |
---|
230 | |
---|
231 | #ifndef LIBFFI_ASM |
---|
232 | #if defined(POWERPC_DARWIN) || defined(POWERPC_AIX) |
---|
233 | struct ffi_aix_trampoline_struct { |
---|
234 | void * code_pointer; /* Pointer to ffi_closure_ASM */ |
---|
235 | void * toc; /* TOC */ |
---|
236 | void * static_chain; /* Pointer to closure */ |
---|
237 | }; |
---|
238 | #else |
---|
239 | #ifndef X86_WIN64 |
---|
240 | #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ |
---|
241 | #endif |
---|
242 | #endif |
---|
243 | #endif |
---|
244 | |
---|
245 | #endif |
---|
246 | #if defined (__i386__) || defined(__x86_64__) |
---|
247 | |
---|
248 | #endif |
---|