OSDN Git Service

Enable build with sun compiler
[pf3gnuchains/gcc-fork.git] / libffi / src / x86 / ffitarget.h
1 /* -----------------------------------------------------------------*-C-*-
2    ffitarget.h - Copyright (c) 1996-2003, 2010  Red Hat, Inc.
3    Copyright (C) 2008  Free Software Foundation, Inc.
4
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
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.
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
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
44 /* ---- Generic type definitions ----------------------------------------- */
45
46 #ifndef LIBFFI_ASM
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
56 typedef unsigned long          ffi_arg;
57 typedef signed long            ffi_sarg;
58 #endif
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
71 #ifdef X86_WIN64
72   FFI_WIN64,
73   FFI_DEFAULT_ABI = FFI_WIN64,
74 #else
75
76   /* ---- Intel x86 and AMD x86-64 - */
77 #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64))
78   FFI_SYSV,
79   FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
80 #if defined(__i386__) || defined(__i386)
81   FFI_DEFAULT_ABI = FFI_SYSV,
82 #else
83   FFI_DEFAULT_ABI = FFI_UNIX64,
84 #endif
85 #endif
86 #endif /* X86_WIN64 */
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
95 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
96 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
97 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
98
99 #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
100 #define FFI_TRAMPOLINE_SIZE 24
101 #define FFI_NATIVE_RAW_API 0
102 #else
103 #ifdef X86_WIN32
104 #define FFI_TRAMPOLINE_SIZE 13
105 #else
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
111 #define FFI_TRAMPOLINE_SIZE 10
112 #endif
113 #endif
114 #ifndef X86_WIN64
115 #define FFI_NATIVE_RAW_API 1    /* x86 has native raw api support */
116 #endif
117 #endif
118
119 #endif
120