1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 2012, 2014 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
33 #ifndef LIBFFI_H
34 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
35 #endif
36
37 /* ---- System specific configurations ----------------------------------- */
38
39 /* For code common to all platforms on x86 and x86_64. */
40 #define X86_ANY
41
42 #if defined (X86_64) && defined (__i386__)
43 #undef X86_64
44 #define X86
45 #endif
46
47 #ifdef X86_WIN64
48 #define FFI_SIZEOF_ARG 8
49 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
50 #endif
51
52 #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
53 //#define FFI_TARGET_HAS_COMPLEX_TYPE
54
55 /* ---- Generic type definitions ----------------------------------------- */
56
57 #ifndef LIBFFI_ASM
58 #ifdef X86_WIN64
59 #ifdef _MSC_VER
60 typedef unsigned __int64 ffi_arg;
61 typedef __int64 ffi_sarg;
62 #else
63 typedef unsigned long long ffi_arg;
64 typedef long long ffi_sarg;
65 #endif
66 #else
67 #if defined __x86_64__ && defined __ILP32__
68 #define FFI_SIZEOF_ARG 8
69 #define FFI_SIZEOF_JAVA_RAW 4
70 typedef unsigned long long ffi_arg;
71 typedef long long ffi_sarg;
72 #else
73 typedef unsigned long ffi_arg;
74 typedef signed long ffi_sarg;
75 #endif
76 #endif
77
78 typedef enum ffi_abi {
79 FFI_FIRST_ABI = 0,
80
81 /* ---- Intel x86 Win32 ---------- */
82 #ifdef X86_WIN32
83 FFI_SYSV,
84 FFI_STDCALL,
85 FFI_THISCALL,
86 FFI_FASTCALL,
87 FFI_MS_CDECL,
88 FFI_PASCAL,
89 FFI_REGISTER,
90 FFI_LAST_ABI,
91 #ifdef _MSC_VER
92 FFI_DEFAULT_ABI = FFI_MS_CDECL
93 #else
94 FFI_DEFAULT_ABI = FFI_SYSV
95 #endif
96
97 #elif defined(X86_WIN64)
98 FFI_WIN64,
99 FFI_LAST_ABI,
100 FFI_DEFAULT_ABI = FFI_WIN64
101
102 #else
103 /* ---- Intel x86 and AMD x86-64 - */
104 FFI_SYSV,
105 FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
106 FFI_THISCALL,
107 FFI_FASTCALL,
108 FFI_STDCALL,
109 FFI_PASCAL,
110 FFI_REGISTER,
111 FFI_LAST_ABI,
112 #if defined(__i386__) || defined(__i386)
113 FFI_DEFAULT_ABI = FFI_SYSV
114 #else
115 FFI_DEFAULT_ABI = FFI_UNIX64
116 #endif
117 #endif
118 } ffi_abi;
119 #endif
120
121 /* ---- Definitions for closures ----------------------------------------- */
122
123 #define FFI_CLOSURES 1
124 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
125 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
126 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
127 #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
128
129 #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
130 #define FFI_TRAMPOLINE_SIZE 24
131 #define FFI_NATIVE_RAW_API 0
132 #else
133 #ifdef X86_WIN32
134 #define FFI_TRAMPOLINE_SIZE 52
135 #else
136 #ifdef X86_WIN64
137 #define FFI_TRAMPOLINE_SIZE 29
138 #define FFI_NATIVE_RAW_API 0
139 #define FFI_NO_RAW_API 1
140 #else
141 #define FFI_TRAMPOLINE_SIZE 10
142 #endif
143 #endif
144 #ifndef X86_WIN64
145 #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
146 #endif
147 #endif
148
149 #endif
150
|
1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 2012, 2014, 2018 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
33 #ifndef LIBFFI_H
34 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
35 #endif
36
37 /* ---- System specific configurations ----------------------------------- */
38
39 /* For code common to all platforms on x86 and x86_64. */
40 #define X86_ANY
41
42 #if defined (X86_64) && defined (__i386__)
43 #undef X86_64
44 #define X86
45 #endif
46
47 #ifdef X86_WIN64
48 #define FFI_SIZEOF_ARG 8
49 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
50 #endif
51
52 #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
53 #ifndef _MSC_VER
54 #define FFI_TARGET_HAS_COMPLEX_TYPE
55 #endif
56
57 /* ---- Generic type definitions ----------------------------------------- */
58
59 #ifndef LIBFFI_ASM
60 #ifdef X86_WIN64
61 #ifdef _MSC_VER
62 typedef unsigned __int64 ffi_arg;
63 typedef __int64 ffi_sarg;
64 #else
65 typedef unsigned long long ffi_arg;
66 typedef long long ffi_sarg;
67 #endif
68 #else
69 #if defined __x86_64__ && defined __ILP32__
70 #define FFI_SIZEOF_ARG 8
71 #define FFI_SIZEOF_JAVA_RAW 4
72 typedef unsigned long long ffi_arg;
73 typedef long long ffi_sarg;
74 #else
75 typedef unsigned long ffi_arg;
76 typedef signed long ffi_sarg;
77 #endif
78 #endif
79
80 typedef enum ffi_abi {
81 #if defined(X86_WIN64)
82 FFI_FIRST_ABI = 0,
83 FFI_WIN64, /* sizeof(long double) == 8 - microsoft compilers */
84 FFI_GNUW64, /* sizeof(long double) == 16 - GNU compilers */
85 FFI_LAST_ABI,
86 #ifdef __GNUC__
87 FFI_DEFAULT_ABI = FFI_GNUW64
88 #else
89 FFI_DEFAULT_ABI = FFI_WIN64
90 #endif
91
92 #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
93 FFI_FIRST_ABI = 1,
94 FFI_UNIX64,
95 FFI_WIN64,
96 FFI_EFI64 = FFI_WIN64,
97 FFI_GNUW64,
98 FFI_LAST_ABI,
99 FFI_DEFAULT_ABI = FFI_UNIX64
100
101 #elif defined(X86_WIN32)
102 FFI_FIRST_ABI = 0,
103 FFI_SYSV = 1,
104 FFI_STDCALL = 2,
105 FFI_THISCALL = 3,
106 FFI_FASTCALL = 4,
107 FFI_MS_CDECL = 5,
108 FFI_PASCAL = 6,
109 FFI_REGISTER = 7,
110 FFI_LAST_ABI,
111 FFI_DEFAULT_ABI = FFI_MS_CDECL
112 #else
113 FFI_FIRST_ABI = 0,
114 FFI_SYSV = 1,
115 FFI_THISCALL = 3,
116 FFI_FASTCALL = 4,
117 FFI_STDCALL = 5,
118 FFI_PASCAL = 6,
119 FFI_REGISTER = 7,
120 FFI_MS_CDECL = 8,
121 FFI_LAST_ABI,
122 FFI_DEFAULT_ABI = FFI_SYSV
123 #endif
124 } ffi_abi;
125 #endif
126
127 /* ---- Definitions for closures ----------------------------------------- */
128
129 #define FFI_CLOSURES 1
130 #define FFI_GO_CLOSURES 1
131
132 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
133 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
134 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
135 #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
136
137 #if defined (X86_64) || defined(X86_WIN64) \
138 || (defined (__x86_64__) && defined (X86_DARWIN))
139 # define FFI_TRAMPOLINE_SIZE 24
140 # define FFI_NATIVE_RAW_API 0
141 #else
142 # define FFI_TRAMPOLINE_SIZE 12
143 # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
144 #endif
145
146 #endif
147
|