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