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.
6 Target configuration macros for x86 and x86-64.
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:
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
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.
28 ----------------------------------------------------------------------- */
30 #ifndef LIBFFI_TARGET_H
31 #define LIBFFI_TARGET_H
34 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
37 /* ---- System specific configurations ----------------------------------- */
39 /* For code common to all platforms on x86 and x86_64. */
42 #if defined (X86_64) && defined (__i386__)
48 #define FFI_SIZEOF_ARG 8
49 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
52 #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
54 #if !defined(_MSC_VER) && !defined(X86_DARWIN) && !defined(X86_64_DARWIN)
55 #define FFI_TARGET_HAS_COMPLEX_TYPE
58 /* ---- Generic type definitions ----------------------------------------- */
63 typedef unsigned __int64 ffi_arg
;
64 typedef __int64 ffi_sarg
;
66 typedef unsigned long long ffi_arg
;
67 typedef long long ffi_sarg
;
70 #if defined __x86_64__ && defined __ILP32__
71 #define FFI_SIZEOF_ARG 8
72 #define FFI_SIZEOF_JAVA_RAW 4
73 typedef unsigned long long ffi_arg
;
74 typedef long long ffi_sarg
;
76 typedef unsigned long ffi_arg
;
77 typedef signed long ffi_sarg
;
81 typedef enum ffi_abi
{
82 #if defined(X86_WIN64)
86 FFI_DEFAULT_ABI
= FFI_WIN64
88 #elif defined(X86_64) || defined(X86_64_DARWIN)
92 FFI_DEFAULT_ABI
= FFI_UNIX64
94 #elif defined(X86_WIN32)
104 FFI_DEFAULT_ABI
= FFI_MS_CDECL
115 FFI_DEFAULT_ABI
= FFI_SYSV
120 /* ---- Definitions for closures ----------------------------------------- */
122 #define FFI_CLOSURES 1
124 #if !defined(X86_DARWIN) && !defined(X86_64_DARWIN)
125 #define FFI_GO_CLOSURES 1
128 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
129 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
130 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
131 #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
133 #if defined (X86_64) || defined(X86_WIN64) || defined(X86_64_DARWIN)
134 # define FFI_TRAMPOLINE_SIZE 24
135 # define FFI_NATIVE_RAW_API 0
137 # define FFI_TRAMPOLINE_SIZE 12
138 # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */