Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 1 | /* -----------------------------------------------------------------*-C-*- |
Matthias Klose | 9a65877 | 2010-03-19 19:02:09 +0000 | [diff] [blame] | 2 | ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc. |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 3 | Copyright (C) 2008 Free Software Foundation, Inc. |
| 4 | |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 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 | |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 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. |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 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 | |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 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 | |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 44 | /* ---- Generic type definitions ----------------------------------------- */ |
| 45 | |
| 46 | #ifndef LIBFFI_ASM |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 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 |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 56 | typedef unsigned long ffi_arg; |
| 57 | typedef signed long ffi_sarg; |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 58 | #endif |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 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 | /* TODO: Add fastcall support for the sake of completeness */ |
| 68 | FFI_DEFAULT_ABI = FFI_SYSV, |
| 69 | #endif |
| 70 | |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 71 | #ifdef X86_WIN64 |
| 72 | FFI_WIN64, |
| 73 | FFI_DEFAULT_ABI = FFI_WIN64, |
| 74 | #else |
| 75 | |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 76 | /* ---- Intel x86 and AMD x86-64 - */ |
Matthias Klose | 9a65877 | 2010-03-19 19:02:09 +0000 | [diff] [blame] | 77 | #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64)) |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 78 | FFI_SYSV, |
| 79 | FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ |
Matthias Klose | 9a65877 | 2010-03-19 19:02:09 +0000 | [diff] [blame] | 80 | #if defined(__i386__) || defined(__i386) |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 81 | FFI_DEFAULT_ABI = FFI_SYSV, |
| 82 | #else |
| 83 | FFI_DEFAULT_ABI = FFI_UNIX64, |
| 84 | #endif |
| 85 | #endif |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 86 | #endif /* X86_WIN64 */ |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 87 | |
| 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 Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 95 | #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) |
| 96 | #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 97 | #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 98 | |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 99 | #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 100 | #define FFI_TRAMPOLINE_SIZE 24 |
| 101 | #define FFI_NATIVE_RAW_API 0 |
| 102 | #else |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 103 | #ifdef X86_WIN32 |
| 104 | #define FFI_TRAMPOLINE_SIZE 13 |
| 105 | #else |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 106 | #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 Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 111 | #define FFI_TRAMPOLINE_SIZE 10 |
Christian Heimes | 7864476 | 2008-03-04 23:39:23 +0000 | [diff] [blame] | 112 | #endif |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 113 | #endif |
| 114 | #ifndef X86_WIN64 |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 115 | #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ |
| 116 | #endif |
Matthias Klose | a834975 | 2010-03-15 13:25:28 +0000 | [diff] [blame] | 117 | #endif |
Thomas Heller | d4c9320 | 2006-03-08 19:35:11 +0000 | [diff] [blame] | 118 | |
| 119 | #endif |
| 120 | |