blob: 89a8983da9a422e55ab112ce9c010025a472254b [file] [log] [blame]
Thomas Hellerd4c93202006-03-08 19:35:11 +00001/* -----------------------------------------------------------------*-C-*-
Matthias Klose9a658772010-03-19 19:02:09 +00002 ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc.
Christian Heimes78644762008-03-04 23:39:23 +00003 Copyright (C) 2008 Free Software Foundation, Inc.
4
Thomas Hellerd4c93202006-03-08 19:35:11 +00005 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
Christian Heimes78644762008-03-04 23:39:23 +000018 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.
Thomas Hellerd4c93202006-03-08 19:35:11 +000026
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
Matthias Klosea8349752010-03-15 13:25:28 +000039#ifdef X86_WIN64
40#define FFI_SIZEOF_ARG 8
41#define USE_BUILTIN_FFS 0 // not yet implemented in mingw-64
42#endif
43
Thomas Hellerd4c93202006-03-08 19:35:11 +000044/* ---- Generic type definitions ----------------------------------------- */
45
46#ifndef LIBFFI_ASM
Matthias Klosea8349752010-03-15 13:25:28 +000047#ifdef X86_WIN64
48#ifdef _MSC_VER
49typedef unsigned __int64 ffi_arg;
50typedef __int64 ffi_sarg;
51#else
52typedef unsigned long long ffi_arg;
53typedef long long ffi_sarg;
54#endif
55#else
Thomas Hellerd4c93202006-03-08 19:35:11 +000056typedef unsigned long ffi_arg;
57typedef signed long ffi_sarg;
Matthias Klosea8349752010-03-15 13:25:28 +000058#endif
Thomas Hellerd4c93202006-03-08 19:35:11 +000059
60typedef enum ffi_abi {
61 FFI_FIRST_ABI = 0,
62
63 /* ---- Intel x86 Win32 ---------- */
64#ifdef X86_WIN32
65 FFI_SYSV,
66 FFI_STDCALL,
67 /* TODO: Add fastcall support for the sake of completeness */
68 FFI_DEFAULT_ABI = FFI_SYSV,
69#endif
70
Matthias Klosea8349752010-03-15 13:25:28 +000071#ifdef X86_WIN64
72 FFI_WIN64,
73 FFI_DEFAULT_ABI = FFI_WIN64,
74#else
75
Thomas Hellerd4c93202006-03-08 19:35:11 +000076 /* ---- Intel x86 and AMD x86-64 - */
Matthias Klose9a658772010-03-19 19:02:09 +000077#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64))
Thomas Hellerd4c93202006-03-08 19:35:11 +000078 FFI_SYSV,
79 FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
Matthias Klose9a658772010-03-19 19:02:09 +000080#if defined(__i386__) || defined(__i386)
Thomas Hellerd4c93202006-03-08 19:35:11 +000081 FFI_DEFAULT_ABI = FFI_SYSV,
82#else
83 FFI_DEFAULT_ABI = FFI_UNIX64,
84#endif
85#endif
Matthias Klosea8349752010-03-15 13:25:28 +000086#endif /* X86_WIN64 */
Thomas Hellerd4c93202006-03-08 19:35:11 +000087
88 FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
89} ffi_abi;
90#endif
91
92/* ---- Definitions for closures ----------------------------------------- */
93
94#define FFI_CLOSURES 1
Christian Heimes78644762008-03-04 23:39:23 +000095#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
96#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
Matthias Klosea8349752010-03-15 13:25:28 +000097#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
Thomas Hellerd4c93202006-03-08 19:35:11 +000098
Christian Heimes78644762008-03-04 23:39:23 +000099#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
Thomas Hellerd4c93202006-03-08 19:35:11 +0000100#define FFI_TRAMPOLINE_SIZE 24
101#define FFI_NATIVE_RAW_API 0
102#else
Christian Heimes78644762008-03-04 23:39:23 +0000103#ifdef X86_WIN32
104#define FFI_TRAMPOLINE_SIZE 13
105#else
Matthias Klosea8349752010-03-15 13:25:28 +0000106#ifdef X86_WIN64
107#define FFI_TRAMPOLINE_SIZE 29
108#define FFI_NATIVE_RAW_API 0
109#define FFI_NO_RAW_API 1
110#else
Thomas Hellerd4c93202006-03-08 19:35:11 +0000111#define FFI_TRAMPOLINE_SIZE 10
Christian Heimes78644762008-03-04 23:39:23 +0000112#endif
Matthias Klosea8349752010-03-15 13:25:28 +0000113#endif
114#ifndef X86_WIN64
Thomas Hellerd4c93202006-03-08 19:35:11 +0000115#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
116#endif
Matthias Klosea8349752010-03-15 13:25:28 +0000117#endif
Thomas Hellerd4c93202006-03-08 19:35:11 +0000118
119#endif
120