Ticket #25439: ffitarget.h

File ffitarget.h, 7.1 KB (added by yugui@…, 14 years ago)

generated ffitarget.h

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