Ruby: ext/fiddle/libffi-3.2.1/src/x86/ffitarget.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

ffitarget.h
Go to the documentation of this file.
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
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.
27
28 ----------------------------------------------------------------------- */
29
30#ifndef LIBFFI_TARGET_H
31#define LIBFFI_TARGET_H
32
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
62typedef unsigned __int64 ffi_arg;
63typedef __int64 ffi_sarg;
64#else
65typedef unsigned long long ffi_arg;
66typedef 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
72typedef unsigned long long ffi_arg;
73typedef 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 FFI_FIRST_ABI = 0,
82
83 /* ---- Intel x86 Win32 ---------- */
84#ifdef X86_WIN32
85 FFI_SYSV,
86 FFI_STDCALL,
87 FFI_THISCALL,
88 FFI_FASTCALL,
89 FFI_MS_CDECL,
90 FFI_PASCAL,
91 FFI_REGISTER,
92 FFI_LAST_ABI,
93#ifdef _MSC_VER
94 FFI_DEFAULT_ABI = FFI_MS_CDECL
95#else
96 FFI_DEFAULT_ABI = FFI_SYSV
97#endif
98
99#elif defined(X86_WIN64)
100 FFI_WIN64,
101 FFI_LAST_ABI,
102 FFI_DEFAULT_ABI = FFI_WIN64
103
104#else
105 /* ---- Intel x86 and AMD x86-64 - */
106 FFI_SYSV,
107 FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
108 FFI_THISCALL,
109 FFI_FASTCALL,
110 FFI_STDCALL,
111 FFI_PASCAL,
112 FFI_REGISTER,
113 FFI_LAST_ABI,
114#if defined(__i386__) || defined(__i386)
115 FFI_DEFAULT_ABI = FFI_SYSV
116#else
117 FFI_DEFAULT_ABI = FFI_UNIX64
118#endif
119#endif
120} ffi_abi;
121#endif
122
123/* ---- Definitions for closures ----------------------------------------- */
124
125#define FFI_CLOSURES 1
126#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
127#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
128#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
129#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
130
131#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
132#define FFI_TRAMPOLINE_SIZE 24
133#define FFI_NATIVE_RAW_API 0
134#else
135#ifdef X86_WIN32
136#define FFI_TRAMPOLINE_SIZE 52
137#else
138#ifdef X86_WIN64
139#define FFI_TRAMPOLINE_SIZE 29
140#define FFI_NATIVE_RAW_API 0
141#define FFI_NO_RAW_API 1
142#else
143#define FFI_TRAMPOLINE_SIZE 10
144#endif
145#endif
146#ifndef X86_WIN64
147#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
148#endif
149#endif
150
151#endif
152
ffi_arg
unsigned long ffi_arg
Definition: ffitarget.h:30
ffi_abi
ffi_abi
Definition: ffitarget.h:34
FFI_SYSV
@ FFI_SYSV
Definition: ffitarget.h:36
FFI_DEFAULT_ABI
@ FFI_DEFAULT_ABI
Definition: ffitarget.h:38
FFI_FIRST_ABI
@ FFI_FIRST_ABI
Definition: ffitarget.h:35
FFI_LAST_ABI
@ FFI_LAST_ABI
Definition: ffitarget.h:37
ffi_sarg
signed long ffi_sarg
Definition: ffitarget.h:31
FFI_FASTCALL
@ FFI_FASTCALL
Definition: ffitarget.h:109
FFI_STDCALL
@ FFI_STDCALL
Definition: ffitarget.h:110
FFI_THISCALL
@ FFI_THISCALL
Definition: ffitarget.h:108
FFI_PASCAL
@ FFI_PASCAL
Definition: ffitarget.h:111
FFI_REGISTER
@ FFI_REGISTER
Definition: ffitarget.h:112
FFI_UNIX64
@ FFI_UNIX64
Definition: ffitarget.h:107