1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 2012 Anthony Green
3 Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc
4 Copyright (c) 1996-2003 Red Hat, Inc.
6 Target configuration macros for PowerPC.
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:
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
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.
28 ----------------------------------------------------------------------- */
30 #ifndef LIBFFI_TARGET_H
31 #define LIBFFI_TARGET_H
34 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
37 /* ---- System specific configurations ----------------------------------- */
39 #if defined (POWERPC) && defined (__powerpc64__) /* linux64 */
43 #elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */
47 #ifndef POWERPC_DARWIN64
48 #define POWERPC_DARWIN64
50 #elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */
57 typedef unsigned long ffi_arg
;
58 typedef signed long ffi_sarg
;
60 typedef enum ffi_abi
{
63 #if defined (POWERPC_AIX)
66 FFI_DEFAULT_ABI
= FFI_AIX
,
69 #elif defined (POWERPC_DARWIN)
72 FFI_DEFAULT_ABI
= FFI_DARWIN
,
76 /* The FFI_COMPAT values are used by old code. Since libffi may be
77 a shared library we have to support old values for backwards
83 FFI_COMPAT_LINUX_SOFT_FLOAT
,
85 # if defined (POWERPC64)
86 /* This bit, always set in new code, must not be set in any of the
87 old FFI_COMPAT values that might be used for 64-bit linux. We
88 only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
91 /* This and following bits can reuse FFI_COMPAT values. */
92 FFI_LINUX_STRUCT_ALIGN
= 1,
93 FFI_LINUX_LONG_DOUBLE_128
= 2,
94 FFI_DEFAULT_ABI
= (FFI_LINUX
95 # ifdef __STRUCT_PARM_ALIGN__
96 | FFI_LINUX_STRUCT_ALIGN
98 # ifdef __LONG_DOUBLE_128__
99 | FFI_LINUX_LONG_DOUBLE_128
105 /* This bit, always set in new code, must not be set in any of the
106 old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */
108 /* This and following bits can reuse FFI_COMPAT values. */
109 FFI_SYSV_SOFT_FLOAT
= 1,
110 FFI_SYSV_STRUCT_RET
= 2,
111 FFI_SYSV_IBM_LONG_DOUBLE
= 4,
112 FFI_SYSV_LONG_DOUBLE_128
= 16,
114 FFI_DEFAULT_ABI
= (FFI_SYSV
116 | FFI_SYSV_SOFT_FLOAT
118 # if (defined (__SVR4_STRUCT_RETURN) \
119 || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
120 | FFI_SYSV_STRUCT_RET
122 # if __LDBL_MANT_DIG__ == 106
123 | FFI_SYSV_IBM_LONG_DOUBLE
125 # ifdef __LONG_DOUBLE_128__
126 | FFI_SYSV_LONG_DOUBLE_128
136 /* ---- Definitions for closures ----------------------------------------- */
138 #define FFI_CLOSURES 1
139 #define FFI_NATIVE_RAW_API 0
140 #if defined (POWERPC) || defined (POWERPC_FREEBSD)
141 # define FFI_GO_CLOSURES 1
142 # define FFI_TARGET_SPECIFIC_VARIADIC 1
143 # define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
145 #if defined (POWERPC_AIX)
146 # define FFI_GO_CLOSURES 1
149 /* ppc_closure.S and linux64_closure.S expect this. */
150 #define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
152 /* We define additional types below. If generic types are added that
153 must be supported by powerpc libffi then it is likely that
154 FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
155 ppc_closure.S and linux64_closure.S be extended. */
157 #if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST \
158 || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX \
159 && !defined FFI_TARGET_HAS_COMPLEX_TYPE))
160 # error "You likely have a broken powerpc libffi"
163 /* Needed for soft-float long-double-128 support. */
164 #define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1)
166 /* Needed for FFI_SYSV small structure returns. */
167 #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2)
169 /* Used by ELFv2 for homogenous structure returns. */
170 #define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1)
171 #define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2)
172 #define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3)
175 # define FFI_TRAMPOLINE_SIZE 32
177 # if defined(POWERPC64) || defined(POWERPC_AIX)
178 # if defined(POWERPC_DARWIN64)
179 # define FFI_TRAMPOLINE_SIZE 48
181 # define FFI_TRAMPOLINE_SIZE 24
183 # else /* POWERPC || POWERPC_AIX */
184 # define FFI_TRAMPOLINE_SIZE 40
189 #if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
190 struct ffi_aix_trampoline_struct
{
191 void * code_pointer
; /* Pointer to ffi_closure_ASM */
192 void * toc
; /* TOC */
193 void * static_chain
; /* Pointer to closure */