aarch64: Always distinguish LONGDOUBLE Avoid if-deffery by forcing FFI_TYPE_LONGDOUBLE different from FFI_TYPE_DOUBLE. This will simply be unused on hosts that define them identically.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index 0834614..f065be5 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -20,11 +20,20 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdio.h>
-
+#include <stdlib.h>
#include <ffi.h>
#include <ffi_common.h>
-#include <stdlib.h>
+/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
+ all further uses in this file will refer to the 128-bit type. */
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+# if FFI_TYPE_LONGDOUBLE != 4
+# error FFI_TYPE_LONGDOUBLE out of date
+# endif
+#else
+# undef FFI_TYPE_LONGDOUBLE
+# define FFI_TYPE_LONGDOUBLE 4
+#endif
/* Stack alignment requirement in bytes */
#if defined (__APPLE__)
@@ -115,10 +124,8 @@ get_basic_type_addr (unsigned short type, struct call_context *context,
return get_s_addr (context, n);
case FFI_TYPE_DOUBLE:
return get_d_addr (context, n);
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
return get_v_addr (context, n);
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16:
@@ -151,10 +158,8 @@ get_basic_type_alignment (unsigned short type)
#endif
case FFI_TYPE_DOUBLE:
return sizeof (UINT64);
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
return sizeof (long double);
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
#if defined (__APPLE__)
@@ -193,10 +198,8 @@ get_basic_type_size (unsigned short type)
return sizeof (UINT32);
case FFI_TYPE_DOUBLE:
return sizeof (UINT64);
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
return sizeof (long double);
-#endif
case FFI_TYPE_UINT8:
return sizeof (UINT8);
case FFI_TYPE_SINT8:
@@ -390,9 +393,7 @@ is_register_candidate (ffi_type *ty)
case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32:
@@ -557,11 +558,9 @@ copy_basic_type (void *dest, void *source, unsigned short type)
case FFI_TYPE_DOUBLE:
*(double *) dest = *(double *) source;
break;
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
*(long double *) dest = *(long double *) source;
break;
-#endif
case FFI_TYPE_UINT8:
*(ffi_arg *) dest = *(UINT8 *) source;
break;
@@ -653,13 +652,11 @@ allocate_to_register_or_stack (struct call_context *context,
return allocate_to_d (context, state);
state->nsrn = N_V_ARG_REG;
break;
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
if (state->nsrn < N_V_ARG_REG)
return allocate_to_v (context, state);
state->nsrn = N_V_ARG_REG;
break;
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16:
@@ -722,9 +719,7 @@ aarch64_prep_args (struct call_context *context, unsigned char *stack,
appropriate register, or if none are available, to the stack. */
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16:
@@ -887,9 +882,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16:
@@ -1040,14 +1033,12 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
case FFI_TYPE_POINTER:
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
- case FFI_TYPE_FLOAT:
- case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
- case FFI_TYPE_LONGDOUBLE:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_LONGDOUBLE:
avalue[i] = allocate_to_register_or_stack (context, stack,
&state, ty->type);
break;
-#endif
case FFI_TYPE_STRUCT:
h = is_hfa (ty);
@@ -1106,13 +1097,11 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
break;
}
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
memcpy (&avalue[i],
allocate_to_v (context, &state),
sizeof (*avalue));
break;
-#endif
default:
FFI_ASSERT (0);
@@ -1183,9 +1172,7 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
{
void *addr = get_basic_type_addr (cif->rtype->type, context, 0);
copy_basic_type (addr, rvalue, cif->rtype->type);