OSDN Git Service

4154762d2506f43830754be841080620b82cfc76
[pf3gnuchains/gcc-fork.git] / libffi / src / x86 / ffitarget.h
1 /* -----------------------------------------------------------------*-C-*-
2    ffitarget.h - Copyright (c) 1996-2003, 2010  Red Hat, Inc.
3    Copyright (C) 2008  Free Software Foundation, Inc.
4
5    Target configuration macros for x86 and x86-64.
6
7    Permission is hereby granted, free of charge, to any person obtaining
8    a copy of this software and associated documentation files (the
9    ``Software''), to deal in the Software without restriction, including
10    without limitation the rights to use, copy, modify, merge, publish,
11    distribute, sublicense, and/or sell copies of the Software, and to
12    permit persons to whom the Software is furnished to do so, subject to
13    the following conditions:
14
15    The above copyright notice and this permission notice shall be included
16    in all copies or substantial portions of the Software.
17
18    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
19    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21    NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25    DEALINGS IN THE SOFTWARE.
26
27    ----------------------------------------------------------------------- */
28
29 #ifndef LIBFFI_TARGET_H
30 #define LIBFFI_TARGET_H
31
32 /* ---- System specific configurations ----------------------------------- */
33
34 #if defined (X86_64) && defined (__i386__)
35 #undef X86_64
36 #define X86
37 #endif
38
39 #ifdef X86_WIN64
40 #define FFI_SIZEOF_ARG 8
41 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
42 #endif
43
44 /* ---- Generic type definitions ----------------------------------------- */
45
46 #ifndef LIBFFI_ASM
47 #ifdef X86_WIN64
48 #ifdef _MSC_VER
49 typedef unsigned __int64       ffi_arg;
50 typedef __int64                ffi_sarg;
51 #else
52 typedef unsigned long long     ffi_arg;
53 typedef long long              ffi_sarg;
54 #endif
55 #else
56 typedef unsigned long          ffi_arg;
57 typedef signed long            ffi_sarg;
58 #endif
59
60 typedef enum ffi_abi {
61   FFI_FIRST_ABI = 0,
62
63   /* ---- Intel x86 Win32 ---------- */
64 #ifdef X86_WIN32
65   FFI_SYSV,
66   FFI_STDCALL,
67   FFI_THISCALL,
68   FFI_FASTCALL,
69   /* TODO: Add fastcall support for the sake of completeness */
70   FFI_DEFAULT_ABI = FFI_SYSV,
71 #endif
72
73 #ifdef X86_WIN64
74   FFI_WIN64,
75   FFI_DEFAULT_ABI = FFI_WIN64,
76 #else
77
78   /* ---- Intel x86 and AMD x86-64 - */
79 #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64))
80   FFI_SYSV,
81   FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
82 #if defined(__i386__) || defined(__i386)
83   FFI_DEFAULT_ABI = FFI_SYSV,
84 #else
85   FFI_DEFAULT_ABI = FFI_UNIX64,
86 #endif
87 #endif
88 #endif /* X86_WIN64 */
89
90   FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
91 } ffi_abi;
92 #endif
93
94 /* ---- Definitions for closures ----------------------------------------- */
95
96 #define FFI_CLOSURES 1
97 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
98 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
99 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
100
101 #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
102 #define FFI_TRAMPOLINE_SIZE 24
103 #define FFI_NATIVE_RAW_API 0
104 #else
105 #ifdef X86_WIN32
106 #define FFI_TRAMPOLINE_SIZE 13
107 #else
108 #ifdef X86_WIN64
109 #define FFI_TRAMPOLINE_SIZE 29
110 #define FFI_NATIVE_RAW_API 0
111 #define FFI_NO_RAW_API 1
112 #else
113 #define FFI_TRAMPOLINE_SIZE 10
114 #endif
115 #endif
116 #ifndef X86_WIN64
117 #define FFI_NATIVE_RAW_API 1    /* x86 has native raw api support */
118 #endif
119 #endif
120
121 #endif
122