Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:29:51

0001 /* -----------------------------------------------------------------*-C-*-
0002    ffitarget.h - Copyright (c) 2012, 2014, 2018  Anthony Green
0003                  Copyright (c) 1996-2003, 2010  Red Hat, Inc.
0004                  Copyright (C) 2008  Free Software Foundation, Inc.
0005 
0006    Target configuration macros for x86 and x86-64.
0007 
0008    Permission is hereby granted, free of charge, to any person obtaining
0009    a copy of this software and associated documentation files (the
0010    ``Software''), to deal in the Software without restriction, including
0011    without limitation the rights to use, copy, modify, merge, publish,
0012    distribute, sublicense, and/or sell copies of the Software, and to
0013    permit persons to whom the Software is furnished to do so, subject to
0014    the following conditions:
0015 
0016    The above copyright notice and this permission notice shall be included
0017    in all copies or substantial portions of the Software.
0018 
0019    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
0020    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0021    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0022    NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
0023    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
0024    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0025    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0026    DEALINGS IN THE SOFTWARE.
0027 
0028    ----------------------------------------------------------------------- */
0029 
0030 #ifndef LIBFFI_TARGET_H
0031 #define LIBFFI_TARGET_H
0032 
0033 #ifndef LIBFFI_H
0034 #error "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
0035 #endif
0036 
0037 /* ---- System specific configurations ----------------------------------- */
0038 
0039 /* For code common to all platforms on x86 and x86_64. */
0040 #define X86_ANY
0041 
0042 #if defined (X86_64) && defined (__i386__)
0043 #undef X86_64
0044 #warning ******************************************************
0045 #warning ********** X86 IS DEFINED ****************************
0046 #warning ******************************************************
0047 #define X86
0048 #endif
0049 
0050 #ifdef X86_WIN64
0051 #define FFI_SIZEOF_ARG 8
0052 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
0053 #endif
0054 
0055 #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
0056 #ifndef _MSC_VER
0057 #define FFI_TARGET_HAS_COMPLEX_TYPE
0058 #endif
0059 
0060 /* ---- Generic type definitions ----------------------------------------- */
0061 
0062 #ifndef LIBFFI_ASM
0063 #ifdef X86_WIN64
0064 #ifdef _MSC_VER
0065 typedef unsigned __int64       ffi_arg;
0066 typedef __int64                ffi_sarg;
0067 #else
0068 typedef unsigned long long     ffi_arg;
0069 typedef long long              ffi_sarg;
0070 #endif
0071 #else
0072 #if defined __x86_64__ && defined __ILP32__
0073 #define FFI_SIZEOF_ARG 8
0074 #define FFI_SIZEOF_JAVA_RAW  4
0075 typedef unsigned long long     ffi_arg;
0076 typedef long long              ffi_sarg;
0077 #else
0078 typedef unsigned long          ffi_arg;
0079 typedef signed long            ffi_sarg;
0080 #endif
0081 #endif
0082 
0083 typedef enum ffi_abi {
0084 #if defined(X86_WIN64)
0085   FFI_FIRST_ABI = 0,
0086   FFI_WIN64,            /* sizeof(long double) == 8  - microsoft compilers */
0087   FFI_GNUW64,           /* sizeof(long double) == 16 - GNU compilers */
0088   FFI_LAST_ABI,
0089 #ifdef __GNUC__
0090   FFI_DEFAULT_ABI = FFI_GNUW64
0091 #else
0092   FFI_DEFAULT_ABI = FFI_WIN64
0093 #endif
0094 
0095 #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
0096   FFI_FIRST_ABI = 1,
0097   FFI_UNIX64,
0098   FFI_WIN64,
0099   FFI_EFI64 = FFI_WIN64,
0100   FFI_GNUW64,
0101   FFI_LAST_ABI,
0102   FFI_DEFAULT_ABI = FFI_UNIX64
0103 
0104 #elif defined(X86_WIN32)
0105   FFI_FIRST_ABI = 0,
0106   FFI_SYSV      = 1,
0107   FFI_STDCALL   = 2,
0108   FFI_THISCALL  = 3,
0109   FFI_FASTCALL  = 4,
0110   FFI_MS_CDECL  = 5,
0111   FFI_PASCAL    = 6,
0112   FFI_REGISTER  = 7,
0113   FFI_LAST_ABI,
0114   FFI_DEFAULT_ABI = FFI_MS_CDECL
0115 #else
0116   FFI_FIRST_ABI = 0,
0117   FFI_SYSV      = 1,
0118   FFI_THISCALL  = 3,
0119   FFI_FASTCALL  = 4,
0120   FFI_STDCALL   = 5,
0121   FFI_PASCAL    = 6,
0122   FFI_REGISTER  = 7,
0123   FFI_MS_CDECL  = 8,
0124   FFI_LAST_ABI,
0125   FFI_DEFAULT_ABI = FFI_SYSV
0126 #endif
0127 } ffi_abi;
0128 #endif
0129 
0130 /* ---- Definitions for closures ----------------------------------------- */
0131 
0132 #define FFI_CLOSURES 1
0133 #define FFI_GO_CLOSURES 1
0134 
0135 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
0136 #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
0137 #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
0138 #define FFI_TYPE_MS_STRUCT       (FFI_TYPE_LAST + 4)
0139 
0140 #if defined (X86_64) || defined(X86_WIN64) \
0141     || (defined (__x86_64__) && defined (X86_DARWIN))
0142 /* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP
0143    + 8 bytes of pointer.  */
0144 # define FFI_TRAMPOLINE_SIZE 32
0145 # define FFI_NATIVE_RAW_API 0
0146 #else
0147 /* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused
0148    bytes.  */
0149 # define FFI_TRAMPOLINE_SIZE 16
0150 # define FFI_NATIVE_RAW_API 1  /* x86 has native raw api support */
0151 #endif
0152 
0153 #if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__)
0154 # include <cet.h>
0155 # if (__CET__ & 1) != 0
0156 #   define ENDBR_PRESENT
0157 # endif
0158 # define _CET_NOTRACK notrack
0159 #else
0160 # define _CET_ENDBR
0161 # define _CET_NOTRACK
0162 #endif
0163 
0164 #endif