1 /* -----------------------------------------------------------------*-C-*-
2    ffitarget.h - Copyright (c) 2012  Anthony Green
3                  Copyright (c) 2010  CodeSourcery
4                  Copyright (c) 1996-2003  Red Hat, Inc.
5 
6    Target configuration macros for ARM.
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 #ifndef LIBFFI_ASM
38 typedef unsigned long          ffi_arg;
39 typedef signed long            ffi_sarg;
40 
41 typedef enum ffi_abi {
42   FFI_FIRST_ABI = 0,
43   FFI_SYSV,
44   FFI_VFP,
45   FFI_LAST_ABI,
46 #if defined(__ARM_PCS_VFP) || defined(_M_ARM)
47   FFI_DEFAULT_ABI = FFI_VFP,
48 #else
49   FFI_DEFAULT_ABI = FFI_SYSV,
50 #endif
51 } ffi_abi;
52 #endif
53 
54 #define FFI_EXTRA_CIF_FIELDS			\
55   int vfp_used;					\
56   unsigned short vfp_reg_free, vfp_nargs;	\
57   signed char vfp_args[16]			\
58 
59 #define FFI_TARGET_SPECIFIC_VARIADIC
60 #ifndef _M_ARM
61 #define FFI_TARGET_HAS_COMPLEX_TYPE
62 #endif
63 
64 /* ---- Definitions for closures ----------------------------------------- */
65 
66 #define FFI_CLOSURES 1
67 #define FFI_GO_CLOSURES 1
68 #define FFI_NATIVE_RAW_API 0
69 
70 #if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE
71 
72 #ifdef __MACH__
73 #define FFI_TRAMPOLINE_SIZE 12
74 #define FFI_TRAMPOLINE_CLOSURE_OFFSET 8
75 #else
76 #error "No trampoline table implementation"
77 #endif
78 
79 #else
80 #ifdef _MSC_VER
81 #define FFI_TRAMPOLINE_SIZE 16
82 #define FFI_TRAMPOLINE_CLOSURE_FUNCTION 12
83 #else
84 #define FFI_TRAMPOLINE_SIZE 12
85 #endif
86 #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
87 #endif
88 
89 #endif
90