1
--- a/src/libffi/configure.ac
2
+++ b/src/libffi/configure.ac
4
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
7
+HAVE_LONG_DOUBLE_VARIANT=0
10
TARGET=AARCH64; TARGETDIR=aarch64
13
powerpc*-*-linux* | powerpc-*-sysv*)
14
TARGET=POWERPC; TARGETDIR=powerpc
15
+ HAVE_LONG_DOUBLE_VARIANT=1
18
TARGET=POWERPC; TARGETDIR=powerpc
21
powerpc-*-freebsd* | powerpc-*-openbsd*)
22
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
23
+ HAVE_LONG_DOUBLE_VARIANT=1
26
TARGET=POWERPC; TARGETDIR=powerpc
28
# Also AC_SUBST this variable for ffi.h.
29
if test -z "$HAVE_LONG_DOUBLE"; then
31
- if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
32
- if test $ac_cv_sizeof_long_double != 0; then
33
+ if test $ac_cv_sizeof_long_double != 0; then
34
+ if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
35
+ AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
37
- AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
39
+ if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
41
+ AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
46
AC_SUBST(HAVE_LONG_DOUBLE)
47
+AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
51
--- a/src/libffi/Makefile.am
52
+++ b/src/libffi/Makefile.am
54
src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S \
55
src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S \
56
src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S \
57
- src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S \
58
- src/powerpc/linux64.S src/powerpc/linux64_closure.S \
59
- src/powerpc/ppc_closure.S src/powerpc/asm.h \
60
- src/powerpc/aix.S src/powerpc/darwin.S \
61
+ src/m68k/ffitarget.h \
62
+ src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
63
+ src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
64
+ src/powerpc/sysv.S src/powerpc/linux64.S \
65
+ src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
66
+ src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
67
src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
68
src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
69
src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
71
nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
74
-nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
75
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
78
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
80
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
83
-nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
84
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
87
nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
88
--- a/src/libffi/man/Makefile.in
89
+++ b/src/libffi/man/Makefile.in
93
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
94
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
96
INSTALL_DATA = @INSTALL_DATA@
97
INSTALL_PROGRAM = @INSTALL_PROGRAM@
98
--- a/src/libffi/configure
99
+++ b/src/libffi/configure
101
FFI_EXEC_TRAMPOLINE_TABLE
102
FFI_EXEC_TRAMPOLINE_TABLE_FALSE
103
FFI_EXEC_TRAMPOLINE_TABLE_TRUE
104
+HAVE_LONG_DOUBLE_VARIANT
108
@@ -10906,7 +10907,7 @@
109
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
110
lt_status=$lt_dlunknown
111
cat > conftest.$ac_ext <<_LT_EOF
112
-#line 10909 "configure"
113
+#line 10910 "configure"
114
#include "confdefs.h"
117
@@ -11012,7 +11013,7 @@
118
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
119
lt_status=$lt_dlunknown
120
cat > conftest.$ac_ext <<_LT_EOF
121
-#line 11015 "configure"
122
+#line 11016 "configure"
123
#include "confdefs.h"
126
@@ -11449,6 +11450,7 @@
130
+HAVE_LONG_DOUBLE_VARIANT=0
133
TARGET=AARCH64; TARGETDIR=aarch64
134
@@ -11546,6 +11548,7 @@
136
powerpc*-*-linux* | powerpc-*-sysv*)
137
TARGET=POWERPC; TARGETDIR=powerpc
138
+ HAVE_LONG_DOUBLE_VARIANT=1
141
TARGET=POWERPC; TARGETDIR=powerpc
142
@@ -11561,6 +11564,7 @@
144
powerpc-*-freebsd* | powerpc-*-openbsd*)
145
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
146
+ HAVE_LONG_DOUBLE_VARIANT=1
148
powerpc64-*-freebsd*)
149
TARGET=POWERPC; TARGETDIR=powerpc
150
@@ -12236,17 +12240,25 @@
151
# Also AC_SUBST this variable for ffi.h.
152
if test -z "$HAVE_LONG_DOUBLE"; then
154
- if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
155
- if test $ac_cv_sizeof_long_double != 0; then
156
+ if test $ac_cv_sizeof_long_double != 0; then
157
+ if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
159
+$as_echo "#define HAVE_LONG_DOUBLE_VARIANT 1" >>confdefs.h
163
+ if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
166
$as_echo "#define HAVE_LONG_DOUBLE 1" >>confdefs.h
175
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
176
$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
177
if test "${ac_cv_c_bigendian+set}" = set; then :
178
--- a/src/libffi/Makefile.in
179
+++ b/src/libffi/Makefile.in
181
@IA64_TRUE@am__append_11 = src/ia64/ffi.c src/ia64/unix.S
182
@M32R_TRUE@am__append_12 = src/m32r/sysv.S src/m32r/ffi.c
183
@M68K_TRUE@am__append_13 = src/m68k/ffi.c src/m68k/sysv.S
184
-@POWERPC_TRUE@am__append_14 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
185
+@POWERPC_TRUE@am__append_14 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
186
@POWERPC_AIX_TRUE@am__append_15 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
187
@POWERPC_DARWIN_TRUE@am__append_16 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
188
-@POWERPC_FREEBSD_TRUE@am__append_17 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
189
+@POWERPC_FREEBSD_TRUE@am__append_17 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
190
@AARCH64_TRUE@am__append_18 = src/aarch64/sysv.S src/aarch64/ffi.c
191
@ARM_TRUE@am__append_19 = src/arm/sysv.S src/arm/ffi.c
192
@ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__append_20 = src/arm/trampoline.S
194
@IA64_TRUE@am__objects_11 = src/ia64/ffi.lo src/ia64/unix.lo
195
@M32R_TRUE@am__objects_12 = src/m32r/sysv.lo src/m32r/ffi.lo
196
@M68K_TRUE@am__objects_13 = src/m68k/ffi.lo src/m68k/sysv.lo
197
-@POWERPC_TRUE@am__objects_14 = src/powerpc/ffi.lo src/powerpc/sysv.lo \
198
+@POWERPC_TRUE@am__objects_14 = src/powerpc/ffi.lo \
199
+@POWERPC_TRUE@ src/powerpc/ffi_sysv.lo \
200
+@POWERPC_TRUE@ src/powerpc/ffi_linux64.lo src/powerpc/sysv.lo \
201
@POWERPC_TRUE@ src/powerpc/ppc_closure.lo \
202
@POWERPC_TRUE@ src/powerpc/linux64.lo \
203
@POWERPC_TRUE@ src/powerpc/linux64_closure.lo
205
@POWERPC_DARWIN_TRUE@ src/powerpc/darwin.lo \
206
@POWERPC_DARWIN_TRUE@ src/powerpc/darwin_closure.lo
207
@POWERPC_FREEBSD_TRUE@am__objects_17 = src/powerpc/ffi.lo \
208
+@POWERPC_FREEBSD_TRUE@ src/powerpc/ffi_sysv.lo \
209
@POWERPC_FREEBSD_TRUE@ src/powerpc/sysv.lo \
210
@POWERPC_FREEBSD_TRUE@ src/powerpc/ppc_closure.lo
211
@AARCH64_TRUE@am__objects_18 = src/aarch64/sysv.lo src/aarch64/ffi.lo
215
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
216
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
218
INSTALL_DATA = @INSTALL_DATA@
219
INSTALL_PROGRAM = @INSTALL_PROGRAM@
220
@@ -387,10 +391,12 @@
221
src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S \
222
src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S \
223
src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S \
224
- src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S \
225
- src/powerpc/linux64.S src/powerpc/linux64_closure.S \
226
- src/powerpc/ppc_closure.S src/powerpc/asm.h \
227
- src/powerpc/aix.S src/powerpc/darwin.S \
228
+ src/m68k/ffitarget.h \
229
+ src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
230
+ src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
231
+ src/powerpc/sysv.S src/powerpc/linux64.S \
232
+ src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
233
+ src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
234
src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
235
src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
236
src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
238
@: > src/powerpc/$(DEPDIR)/$(am__dirstamp)
239
src/powerpc/ffi.lo: src/powerpc/$(am__dirstamp) \
240
src/powerpc/$(DEPDIR)/$(am__dirstamp)
241
+src/powerpc/ffi_sysv.lo: src/powerpc/$(am__dirstamp) \
242
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
243
+src/powerpc/ffi_linux64.lo: src/powerpc/$(am__dirstamp) \
244
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
245
src/powerpc/sysv.lo: src/powerpc/$(am__dirstamp) \
246
src/powerpc/$(DEPDIR)/$(am__dirstamp)
247
src/powerpc/ppc_closure.lo: src/powerpc/$(am__dirstamp) \
249
-rm -f src/powerpc/ffi.lo
250
-rm -f src/powerpc/ffi_darwin.$(OBJEXT)
251
-rm -f src/powerpc/ffi_darwin.lo
252
+ -rm -f src/powerpc/ffi_linux64.$(OBJEXT)
253
+ -rm -f src/powerpc/ffi_linux64.lo
254
+ -rm -f src/powerpc/ffi_sysv.$(OBJEXT)
255
+ -rm -f src/powerpc/ffi_sysv.lo
256
-rm -f src/powerpc/linux64.$(OBJEXT)
257
-rm -f src/powerpc/linux64.lo
258
-rm -f src/powerpc/linux64_closure.$(OBJEXT)
259
@@ -1009,6 +1023,8 @@
260
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/darwin_closure.Plo@am__quote@
261
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi.Plo@am__quote@
262
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_darwin.Plo@am__quote@
263
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_linux64.Plo@am__quote@
264
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_sysv.Plo@am__quote@
265
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64.Plo@am__quote@
266
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64_closure.Plo@am__quote@
267
@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ppc_closure.Plo@am__quote@
268
--- a/src/libffi/include/ffi.h.in
269
+++ b/src/libffi/include/ffi.h.in
274
+#if HAVE_LONG_DOUBLE_VARIANT
275
+/* Used to adjust size/alignment of ffi types. */
276
+void ffi_prep_types (ffi_abi abi);
279
/* Used internally, but overridden by some architectures */
280
ffi_status ffi_prep_cif_core(ffi_cif *cif,
282
--- a/src/libffi/include/Makefile.in
283
+++ b/src/libffi/include/Makefile.in
287
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
288
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
290
INSTALL_DATA = @INSTALL_DATA@
291
INSTALL_PROGRAM = @INSTALL_PROGRAM@
292
--- a/src/libffi/fficonfig.h.in
293
+++ b/src/libffi/fficonfig.h.in
295
/* Define if you have the long double type and it is bigger than a double */
296
#undef HAVE_LONG_DOUBLE
298
+/* Define if you support more than one size of the long double type */
299
+#undef HAVE_LONG_DOUBLE_VARIANT
301
/* Define to 1 if you have the `memcpy' function. */
304
--- a/src/libffi/src/prep_cif.c
305
+++ b/src/libffi/src/prep_cif.c
310
+#if HAVE_LONG_DOUBLE_VARIANT
311
+ ffi_prep_types (abi);
314
/* Initialize the return type if necessary */
315
if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
316
return FFI_BAD_TYPEDEF;
317
--- a/src/libffi/src/powerpc/ffi.c
318
+++ b/src/libffi/src/powerpc/ffi.c
320
/* -----------------------------------------------------------------------
321
- ffi.c - Copyright (C) 2011 Anthony Green
322
+ ffi.c - Copyright (C) 2013 IBM
323
+ Copyright (C) 2011 Anthony Green
324
Copyright (C) 2011 Kyle Moffett
325
Copyright (C) 2008 Red Hat, Inc
326
Copyright (C) 2007, 2008 Free Software Foundation, Inc
327
@@ -27,1112 +28,60 @@
328
OTHER DEALINGS IN THE SOFTWARE.
329
----------------------------------------------------------------------- */
332
-#include <ffi_common.h>
334
+#include "ffi_common.h"
335
+#include "ffi_powerpc.h"
341
-extern void ffi_closure_SYSV (void);
342
-extern void FFI_HIDDEN ffi_closure_LINUX64 (void);
345
- /* The assembly depends on these exact flags. */
346
- FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
347
- FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */
349
- FLAG_RETURNS_FP = 1 << (31-29),
351
- FLAG_RETURNS_64BITS = 1 << (31-28),
353
- FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
355
- FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
356
- FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by ELFv2 */
358
- FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
360
- FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
361
- FLAG_RETVAL_REFERENCE = 1 << (31- 4)
364
-/* About the SYSV ABI. */
365
-#define ASM_NEEDS_REGISTERS 4
366
-#define NUM_GPR_ARG_REGISTERS 8
368
-# define NUM_FPR_ARG_REGISTERS 8
371
-/* ffi_prep_args_SYSV is called by the assembly routine once stack space
372
- has been allocated for the function's arguments.
374
- The stack layout we want looks like this:
376
- | Return address from ffi_call_SYSV 4bytes | higher addresses
377
- |--------------------------------------------|
378
- | Previous backchain pointer 4 | stack pointer here
379
- |--------------------------------------------|<+ <<< on entry to
380
- | Saved r28-r31 4*4 | | ffi_call_SYSV
381
- |--------------------------------------------| |
382
- | GPR registers r3-r10 8*4 | | ffi_call_SYSV
383
- |--------------------------------------------| |
384
- | FPR registers f1-f8 (optional) 8*8 | |
385
- |--------------------------------------------| | stack |
386
- | Space for copied structures | | grows |
387
- |--------------------------------------------| | down V
388
- | Parameters that didn't fit in registers | |
389
- |--------------------------------------------| | lower addresses
390
- | Space for callee's LR 4 | |
391
- |--------------------------------------------| | stack pointer here
392
- | Current backchain pointer 4 |-/ during
393
- |--------------------------------------------| <<< ffi_call_SYSV
398
-ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
399
+#if HAVE_LONG_DOUBLE_VARIANT
400
+/* Adjust ffi_type_longdouble. */
402
+ffi_prep_types (ffi_abi abi)
404
- const unsigned bytes = ecif->cif->bytes;
405
- const unsigned flags = ecif->cif->flags;
415
- /* 'stacktop' points at the previous backchain pointer. */
418
- /* 'gpr_base' points at the space for gpr3, and grows upwards as
419
- we use GPR registers. */
424
- /* 'fpr_base' points at the space for fpr1, and grows upwards as
425
- we use FPR registers. */
430
- /* 'copy_space' grows down as we put structures in it. It should
431
- stay 16-byte aligned. */
434
- /* 'next_arg' grows up as we put parameters in it. */
446
- unsigned char **uc;
448
- unsigned short **us;
454
- size_t struct_copy_size;
457
- stacktop.c = (char *) stack + bytes;
458
- gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
461
- fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
463
- copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
465
- copy_space.c = gpr_base.c;
467
- next_arg.u = stack + 2;
469
- /* Check that everything starts aligned properly. */
470
- FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
471
- FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
472
- FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
473
- FFI_ASSERT ((bytes & 0xF) == 0);
474
- FFI_ASSERT (copy_space.c >= next_arg.c);
476
- /* Deal with return values that are actually pass-by-reference. */
477
- if (flags & FLAG_RETVAL_REFERENCE)
479
- *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
483
- /* Now for the arguments. */
484
- p_argv.v = ecif->avalue;
485
- for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
487
- i--, ptr++, p_argv.v++)
489
- unsigned short typenum = (*ptr)->type;
491
- /* We may need to handle some values depending on ABI */
492
- if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) {
493
- if (typenum == FFI_TYPE_FLOAT)
494
- typenum = FFI_TYPE_UINT32;
495
- if (typenum == FFI_TYPE_DOUBLE)
496
- typenum = FFI_TYPE_UINT64;
497
- if (typenum == FFI_TYPE_LONGDOUBLE)
498
- typenum = FFI_TYPE_UINT128;
499
- } else if (ecif->cif->abi != FFI_LINUX) {
500
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
501
- if (typenum == FFI_TYPE_LONGDOUBLE)
502
- typenum = FFI_TYPE_STRUCT;
506
- /* Now test the translated value */
509
- case FFI_TYPE_FLOAT:
510
- /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
511
- double_tmp = **p_argv.f;
512
- if (fparg_count >= NUM_FPR_ARG_REGISTERS)
514
- *next_arg.f = (float) double_tmp;
519
- *fpr_base.d++ = double_tmp;
521
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
524
- case FFI_TYPE_DOUBLE:
525
- /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
526
- double_tmp = **p_argv.d;
528
- if (fparg_count >= NUM_FPR_ARG_REGISTERS)
530
- if (intarg_count >= NUM_GPR_ARG_REGISTERS
531
- && intarg_count % 2 != 0)
536
- *next_arg.d = double_tmp;
540
- *fpr_base.d++ = double_tmp;
542
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
545
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
546
- case FFI_TYPE_LONGDOUBLE:
547
- double_tmp = (*p_argv.d)[0];
549
- if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
551
- if (intarg_count >= NUM_GPR_ARG_REGISTERS
552
- && intarg_count % 2 != 0)
557
- *next_arg.d = double_tmp;
559
- double_tmp = (*p_argv.d)[1];
560
- *next_arg.d = double_tmp;
565
- *fpr_base.d++ = double_tmp;
566
- double_tmp = (*p_argv.d)[1];
567
- *fpr_base.d++ = double_tmp;
571
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
574
-#endif /* have FPRs */
577
- * The soft float ABI for long doubles works like this, a long double
578
- * is passed in four consecutive GPRs if available. A maximum of 2
579
- * long doubles can be passed in gprs. If we do not have 4 GPRs
580
- * left, the long double is passed on the stack, 4-byte aligned.
582
- case FFI_TYPE_UINT128: {
583
- unsigned int int_tmp = (*p_argv.ui)[0];
585
- if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) {
586
- if (intarg_count < NUM_GPR_ARG_REGISTERS)
587
- intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
588
- *(next_arg.u++) = int_tmp;
589
- for (ii = 1; ii < 4; ii++) {
590
- int_tmp = (*p_argv.ui)[ii];
591
- *(next_arg.u++) = int_tmp;
594
- *(gpr_base.u++) = int_tmp;
595
- for (ii = 1; ii < 4; ii++) {
596
- int_tmp = (*p_argv.ui)[ii];
597
- *(gpr_base.u++) = int_tmp;
604
- case FFI_TYPE_UINT64:
605
- case FFI_TYPE_SINT64:
606
- if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
608
- if (intarg_count >= NUM_GPR_ARG_REGISTERS)
610
- if (intarg_count % 2 != 0)
615
- *next_arg.ll = **p_argv.ll;
620
- /* whoops: abi states only certain register pairs
621
- * can be used for passing long long int
622
- * specifically (r3,r4), (r5,r6), (r7,r8),
623
- * (r9,r10) and if next arg is long long but
624
- * not correct starting register of pair then skip
625
- * until the proper starting register
627
- if (intarg_count % 2 != 0)
632
- *gpr_base.ll++ = **p_argv.ll;
637
- case FFI_TYPE_STRUCT:
638
- struct_copy_size = ((*ptr)->size + 15) & ~0xF;
639
- copy_space.c -= struct_copy_size;
640
- memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
642
- gprvalue = (unsigned long) copy_space.c;
644
- FFI_ASSERT (copy_space.c > next_arg.c);
645
- FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
648
- case FFI_TYPE_UINT8:
649
- gprvalue = **p_argv.uc;
651
- case FFI_TYPE_SINT8:
652
- gprvalue = **p_argv.sc;
654
- case FFI_TYPE_UINT16:
655
- gprvalue = **p_argv.us;
657
- case FFI_TYPE_SINT16:
658
- gprvalue = **p_argv.ss;
662
- case FFI_TYPE_UINT32:
663
- case FFI_TYPE_SINT32:
664
- case FFI_TYPE_POINTER:
666
- gprvalue = **p_argv.ui;
669
- if (intarg_count >= NUM_GPR_ARG_REGISTERS)
670
- *next_arg.u++ = gprvalue;
672
- *gpr_base.u++ = gprvalue;
678
- /* Check that we didn't overrun the stack... */
679
- FFI_ASSERT (copy_space.c >= next_arg.c);
680
- FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
681
- /* The assert below is testing that the number of integer arguments agrees
682
- with the number found in ffi_prep_cif_machdep(). However, intarg_count
683
- is incremented whenever we place an FP arg on the stack, so account for
684
- that before our assert test. */
686
- if (fparg_count > NUM_FPR_ARG_REGISTERS)
687
- intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
688
- FFI_ASSERT (fpr_base.u
689
- <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
691
- FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
692
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
694
+ ffi_prep_types_linux64 (abi);
696
+ ffi_prep_types_sysv (abi);
701
-/* About the LINUX64 ABI. */
703
- NUM_GPR_ARG_REGISTERS64 = 8,
704
- NUM_FPR_ARG_REGISTERS64 = 13
706
-enum { ASM_NEEDS_REGISTERS64 = 4 };
710
-discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
714
- case FFI_TYPE_FLOAT:
715
- case FFI_TYPE_DOUBLE:
717
- return (int) t->type;
719
- case FFI_TYPE_STRUCT:;
721
- unsigned int base_elt = 0, total_elnum = 0;
722
- ffi_type **el = t->elements;
725
- unsigned int el_elt, el_elnum = 0;
726
- el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
728
- || (base_elt && base_elt != el_elt))
731
- total_elnum += el_elnum;
732
- if (total_elnum > 8)
736
- *elnum = total_elnum;
747
-/* ffi_prep_args64 is called by the assembly routine once stack space
748
- has been allocated for the function's arguments.
750
- The stack layout we want looks like this:
752
- | Ret addr from ffi_call_LINUX64 8bytes | higher addresses
753
- |--------------------------------------------|
754
- | CR save area 8bytes |
755
- |--------------------------------------------|
756
- | Previous backchain pointer 8 | stack pointer here
757
- |--------------------------------------------|<+ <<< on entry to
758
- | Saved r28-r31 4*8 | | ffi_call_LINUX64
759
- |--------------------------------------------| |
760
- | GPR registers r3-r10 8*8 | |
761
- |--------------------------------------------| |
762
- | FPR registers f1-f13 (optional) 13*8 | |
763
- |--------------------------------------------| |
764
- | Parameter save area | |
765
- |--------------------------------------------| |
766
- | TOC save area 8 | |
767
- |--------------------------------------------| | stack |
768
- | Linker doubleword 8 | | grows |
769
- |--------------------------------------------| | down V
770
- | Compiler doubleword 8 | |
771
- |--------------------------------------------| | lower addresses
772
- | Space for callee's LR 8 | |
773
- |--------------------------------------------| |
774
- | CR save area 8 | |
775
- |--------------------------------------------| | stack pointer here
776
- | Current backchain pointer 8 |-/ during
777
- |--------------------------------------------| <<< ffi_call_LINUX64
782
-ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
784
- const unsigned long bytes = ecif->cif->bytes;
785
- const unsigned long flags = ecif->cif->flags;
795
- /* 'stacktop' points at the previous backchain pointer. */
798
- /* 'next_arg' points at the space for gpr3, and grows upwards as
799
- we use GPR registers, then continues at rest. */
805
- /* 'fpr_base' points at the space for fpr3, and grows upwards as
806
- we use FPR registers. */
808
- unsigned int fparg_count;
810
- unsigned int i, words, nargs, nfixedargs;
817
- unsigned char **uc;
819
- unsigned short **us;
822
- unsigned long **ul;
826
- unsigned long gprvalue;
827
-#ifdef __STRUCT_PARM_ALIGN__
828
- unsigned long align;
831
- stacktop.c = (char *) stack + bytes;
832
- gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
833
- gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
835
- rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64;
837
- rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
839
- fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
841
- next_arg.ul = gpr_base.ul;
843
- /* Check that everything starts aligned properly. */
844
- FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
845
- FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
846
- FFI_ASSERT ((bytes & 0xF) == 0);
848
- /* Deal with return values that are actually pass-by-reference. */
849
- if (flags & FLAG_RETVAL_REFERENCE)
850
- *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
852
- /* Now for the arguments. */
853
- p_argv.v = ecif->avalue;
854
- nargs = ecif->cif->nargs;
855
- nfixedargs = ecif->cif->nfixedargs;
856
- for (ptr = ecif->cif->arg_types, i = 0;
858
- i++, ptr++, p_argv.v++)
860
- unsigned int elt, elnum;
862
- switch ((*ptr)->type)
864
- case FFI_TYPE_FLOAT:
865
- double_tmp = **p_argv.f;
866
- if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
867
- *fpr_base.d++ = double_tmp;
869
- *next_arg.f = (float) double_tmp;
870
- if (++next_arg.ul == gpr_end.ul)
871
- next_arg.ul = rest.ul;
873
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
876
- case FFI_TYPE_DOUBLE:
877
- double_tmp = **p_argv.d;
878
- if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
879
- *fpr_base.d++ = double_tmp;
881
- *next_arg.d = double_tmp;
882
- if (++next_arg.ul == gpr_end.ul)
883
- next_arg.ul = rest.ul;
885
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
888
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
889
- case FFI_TYPE_LONGDOUBLE:
890
- double_tmp = (*p_argv.d)[0];
891
- if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
892
- *fpr_base.d++ = double_tmp;
894
- *next_arg.d = double_tmp;
895
- if (++next_arg.ul == gpr_end.ul)
896
- next_arg.ul = rest.ul;
898
- double_tmp = (*p_argv.d)[1];
899
- if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
900
- *fpr_base.d++ = double_tmp;
902
- *next_arg.d = double_tmp;
903
- if (++next_arg.ul == gpr_end.ul)
904
- next_arg.ul = rest.ul;
906
- FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
907
- FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
911
- case FFI_TYPE_STRUCT:
912
-#ifdef __STRUCT_PARM_ALIGN__
913
- align = (*ptr)->alignment;
914
- if (align > __STRUCT_PARM_ALIGN__)
915
- align = __STRUCT_PARM_ALIGN__;
917
- next_arg.p = ALIGN (next_arg.p, align);
921
- elt = discover_homogeneous_aggregate (*ptr, &elnum);
932
- if (elt == FFI_TYPE_FLOAT)
936
- double_tmp = *arg.f++;
937
- if (fparg_count < NUM_FPR_ARG_REGISTERS64
939
- *fpr_base.d++ = double_tmp;
941
- *next_arg.f = (float) double_tmp;
942
- if (++next_arg.f == gpr_end.f)
943
- next_arg.f = rest.f;
946
- while (--elnum != 0);
947
- if ((next_arg.p & 3) != 0)
949
- if (++next_arg.f == gpr_end.f)
950
- next_arg.f = rest.f;
956
- double_tmp = *arg.d++;
957
- if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
958
- *fpr_base.d++ = double_tmp;
960
- *next_arg.d = double_tmp;
961
- if (++next_arg.d == gpr_end.d)
962
- next_arg.d = rest.d;
965
- while (--elnum != 0);
969
- words = ((*ptr)->size + 7) / 8;
970
- if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
972
- size_t first = gpr_end.c - next_arg.c;
973
- memcpy (next_arg.c, *p_argv.c, first);
974
- memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
975
- next_arg.c = rest.c + words * 8 - first;
979
- char *where = next_arg.c;
981
-#ifndef __LITTLE_ENDIAN__
982
- /* Structures with size less than eight bytes are passed
984
- if ((*ptr)->size < 8)
985
- where += 8 - (*ptr)->size;
987
- memcpy (where, *p_argv.c, (*ptr)->size);
988
- next_arg.ul += words;
989
- if (next_arg.ul == gpr_end.ul)
990
- next_arg.ul = rest.ul;
995
- case FFI_TYPE_UINT8:
996
- gprvalue = **p_argv.uc;
998
- case FFI_TYPE_SINT8:
999
- gprvalue = **p_argv.sc;
1001
- case FFI_TYPE_UINT16:
1002
- gprvalue = **p_argv.us;
1004
- case FFI_TYPE_SINT16:
1005
- gprvalue = **p_argv.ss;
1007
- case FFI_TYPE_UINT32:
1008
- gprvalue = **p_argv.ui;
1010
- case FFI_TYPE_INT:
1011
- case FFI_TYPE_SINT32:
1012
- gprvalue = **p_argv.si;
1015
- case FFI_TYPE_UINT64:
1016
- case FFI_TYPE_SINT64:
1017
- case FFI_TYPE_POINTER:
1018
- gprvalue = **p_argv.ul;
1020
- *next_arg.ul++ = gprvalue;
1021
- if (next_arg.ul == gpr_end.ul)
1022
- next_arg.ul = rest.ul;
1027
- FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
1028
- || (next_arg.ul >= gpr_base.ul
1029
- && next_arg.ul <= gpr_base.ul + 4));
1034
/* Perform machine dependent cif processing */
1036
-ffi_prep_cif_machdep_core (ffi_cif *cif)
1037
+ffi_status FFI_HIDDEN
1038
+ffi_prep_cif_machdep (ffi_cif *cif)
1040
- /* All this is for the SYSV and LINUX64 ABI. */
1043
- unsigned i, fparg_count = 0, intarg_count = 0;
1044
- unsigned flags = cif->flags;
1045
- unsigned struct_copy_size = 0;
1046
- unsigned type = cif->rtype->type;
1047
- unsigned size = cif->rtype->size;
1049
- /* The machine-independent calculation of cif->bytes doesn't work
1050
- for us. Redo the calculation. */
1051
- if (cif->abi != FFI_LINUX64)
1053
- /* Space for the frame pointer, callee's LR, and the asm's temp regs. */
1054
- bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
1056
- /* Space for the GPR registers. */
1057
- bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
1063
- /* Space for backchain, CR, LR, TOC and the asm's temp regs. */
1064
- bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long);
1066
- /* Space for the general registers. */
1067
- bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long);
1069
+ return ffi_prep_cif_linux64 (cif);
1071
- /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
1073
- bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
1075
- /* Space for the mandatory parm save area and general registers. */
1076
- bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
1077
+ return ffi_prep_cif_sysv (cif);
1081
- /* Return value handling. The rules for SYSV are as follows:
1082
- - 32-bit (or less) integer values are returned in gpr3;
1083
- - Structures of size <= 4 bytes also returned in gpr3;
1084
- - 64-bit integer values and structures between 5 and 8 bytes are returned
1086
- - Single/double FP values are returned in fpr1;
1087
- - Larger structures are allocated space and a pointer is passed as
1088
- the first argument.
1089
- - long doubles (if not equivalent to double) are returned in
1090
- fpr1,fpr2 for Linux and as for large structs for SysV.
1092
- - integer values in gpr3;
1093
- - Structures/Unions by reference;
1094
- - Single/double FP values in fpr1, long double in fpr1,fpr2.
1095
- - soft-float float/doubles are treated as UINT32/UINT64 respectivley.
1096
- - soft-float long doubles are returned in gpr3-gpr6. */
1097
- /* First translate for softfloat/nonlinux */
1098
- if (cif->abi == FFI_LINUX_SOFT_FLOAT)
1100
- if (type == FFI_TYPE_FLOAT)
1101
- type = FFI_TYPE_UINT32;
1102
- if (type == FFI_TYPE_DOUBLE)
1103
- type = FFI_TYPE_UINT64;
1104
- if (type == FFI_TYPE_LONGDOUBLE)
1105
- type = FFI_TYPE_UINT128;
1107
- else if (cif->abi != FFI_LINUX
1108
- && cif->abi != FFI_LINUX64)
1110
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1111
- if (type == FFI_TYPE_LONGDOUBLE)
1112
- type = FFI_TYPE_STRUCT;
1118
-#ifndef __NO_FPRS__
1119
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1120
- case FFI_TYPE_LONGDOUBLE:
1121
- flags |= FLAG_RETURNS_128BITS;
1122
- /* Fall through. */
1124
- case FFI_TYPE_DOUBLE:
1125
- flags |= FLAG_RETURNS_64BITS;
1126
- /* Fall through. */
1127
- case FFI_TYPE_FLOAT:
1128
- flags |= FLAG_RETURNS_FP;
1132
- case FFI_TYPE_UINT128:
1133
- flags |= FLAG_RETURNS_128BITS;
1134
- /* Fall through. */
1135
- case FFI_TYPE_UINT64:
1136
- case FFI_TYPE_SINT64:
1137
- flags |= FLAG_RETURNS_64BITS;
1140
- case FFI_TYPE_STRUCT:
1142
- * The final SYSV ABI says that structures smaller or equal 8 bytes
1143
- * are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
1146
- * NOTE: The assembly code can safely assume that it just needs to
1147
- * store both r3 and r4 into a 8-byte word-aligned buffer, as
1148
- * we allocate a temporary buffer in ffi_call() if this flag is
1151
- if (cif->abi == FFI_SYSV && size <= 8)
1153
- flags |= FLAG_RETURNS_SMST;
1157
- if (cif->abi == FFI_LINUX64)
1159
- unsigned int elt, elnum;
1160
- elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
1163
- if (elt == FFI_TYPE_DOUBLE)
1164
- flags |= FLAG_RETURNS_64BITS;
1165
- flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
1170
- flags |= FLAG_RETURNS_SMST;
1176
- flags |= FLAG_RETVAL_REFERENCE;
1177
- /* Fall through. */
1178
- case FFI_TYPE_VOID:
1179
- flags |= FLAG_RETURNS_NOTHING;
1183
- /* Returns 32-bit integer, or similar. Nothing to do here. */
1187
- if (cif->abi != FFI_LINUX64)
1188
- /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
1189
- first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
1190
- goes on the stack. Structures and long doubles (if not equivalent
1191
- to double) are passed as a pointer to a copy of the structure.
1192
- Stuff on the stack needs to keep proper alignment. */
1193
- for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
1195
- unsigned short typenum = (*ptr)->type;
1197
- /* We may need to handle some values depending on ABI */
1198
- if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
1199
- if (typenum == FFI_TYPE_FLOAT)
1200
- typenum = FFI_TYPE_UINT32;
1201
- if (typenum == FFI_TYPE_DOUBLE)
1202
- typenum = FFI_TYPE_UINT64;
1203
- if (typenum == FFI_TYPE_LONGDOUBLE)
1204
- typenum = FFI_TYPE_UINT128;
1205
- } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
1206
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1207
- if (typenum == FFI_TYPE_LONGDOUBLE)
1208
- typenum = FFI_TYPE_STRUCT;
1212
- switch (typenum) {
1213
-#ifndef __NO_FPRS__
1214
- case FFI_TYPE_FLOAT:
1216
- /* floating singles are not 8-aligned on stack */
1219
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1220
- case FFI_TYPE_LONGDOUBLE:
1224
- case FFI_TYPE_DOUBLE:
1226
- /* If this FP arg is going on the stack, it must be
1227
- 8-byte-aligned. */
1228
- if (fparg_count > NUM_FPR_ARG_REGISTERS
1229
- && intarg_count >= NUM_GPR_ARG_REGISTERS
1230
- && intarg_count % 2 != 0)
1234
- case FFI_TYPE_UINT128:
1236
- * A long double in FFI_LINUX_SOFT_FLOAT can use only a set
1237
- * of four consecutive gprs. If we do not have enough, we
1238
- * have to adjust the intarg_count value.
1240
- if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
1241
- && intarg_count < NUM_GPR_ARG_REGISTERS)
1242
- intarg_count = NUM_GPR_ARG_REGISTERS;
1243
- intarg_count += 4;
1246
- case FFI_TYPE_UINT64:
1247
- case FFI_TYPE_SINT64:
1248
- /* 'long long' arguments are passed as two words, but
1249
- either both words must fit in registers or both go
1250
- on the stack. If they go on the stack, they must
1251
- be 8-byte-aligned.
1253
- Also, only certain register pairs can be used for
1254
- passing long long int -- specifically (r3,r4), (r5,r6),
1255
- (r7,r8), (r9,r10).
1257
- if (intarg_count == NUM_GPR_ARG_REGISTERS-1
1258
- || intarg_count % 2 != 0)
1260
- intarg_count += 2;
1263
- case FFI_TYPE_STRUCT:
1264
- /* We must allocate space for a copy of these to enforce
1265
- pass-by-value. Pad the space up to a multiple of 16
1266
- bytes (the maximum alignment required for anything under
1268
- struct_copy_size += ((*ptr)->size + 15) & ~0xF;
1269
- /* Fall through (allocate space for the pointer). */
1271
- case FFI_TYPE_POINTER:
1272
- case FFI_TYPE_INT:
1273
- case FFI_TYPE_UINT32:
1274
- case FFI_TYPE_SINT32:
1275
- case FFI_TYPE_UINT16:
1276
- case FFI_TYPE_SINT16:
1277
- case FFI_TYPE_UINT8:
1278
- case FFI_TYPE_SINT8:
1279
- /* Everything else is passed as a 4-byte word in a GPR, either
1280
- the object itself or a pointer to it. */
1288
- for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
1290
- unsigned int elt, elnum;
1291
-#ifdef __STRUCT_PARM_ALIGN__
1292
- unsigned int align;
1295
- switch ((*ptr)->type)
1297
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1298
- case FFI_TYPE_LONGDOUBLE:
1300
- intarg_count += 2;
1301
- if (fparg_count > NUM_FPR_ARG_REGISTERS)
1302
- flags |= FLAG_ARG_NEEDS_PSAVE;
1305
- case FFI_TYPE_FLOAT:
1306
- case FFI_TYPE_DOUBLE:
1309
- if (fparg_count > NUM_FPR_ARG_REGISTERS)
1310
- flags |= FLAG_ARG_NEEDS_PSAVE;
1313
- case FFI_TYPE_STRUCT:
1314
-#ifdef __STRUCT_PARM_ALIGN__
1315
- align = (*ptr)->alignment;
1316
- if (align > __STRUCT_PARM_ALIGN__)
1317
- align = __STRUCT_PARM_ALIGN__;
1318
- align = align / 8;
1320
- intarg_count = ALIGN (intarg_count, align);
1322
- intarg_count += ((*ptr)->size + 7) / 8;
1325
- elt = discover_homogeneous_aggregate (*ptr, &elnum);
1329
- fparg_count += elnum;
1330
- if (fparg_count > NUM_FPR_ARG_REGISTERS)
1331
- flags |= FLAG_ARG_NEEDS_PSAVE;
1335
- if (intarg_count > NUM_GPR_ARG_REGISTERS)
1336
- flags |= FLAG_ARG_NEEDS_PSAVE;
1340
- case FFI_TYPE_POINTER:
1341
- case FFI_TYPE_UINT64:
1342
- case FFI_TYPE_SINT64:
1343
- case FFI_TYPE_INT:
1344
- case FFI_TYPE_UINT32:
1345
- case FFI_TYPE_SINT32:
1346
- case FFI_TYPE_UINT16:
1347
- case FFI_TYPE_SINT16:
1348
- case FFI_TYPE_UINT8:
1349
- case FFI_TYPE_SINT8:
1350
- /* Everything else is passed as a 8-byte word in a GPR, either
1351
- the object itself or a pointer to it. */
1353
- if (intarg_count > NUM_GPR_ARG_REGISTERS)
1354
- flags |= FLAG_ARG_NEEDS_PSAVE;
1361
-#ifndef __NO_FPRS__
1362
- if (fparg_count != 0)
1363
- flags |= FLAG_FP_ARGUMENTS;
1365
- if (intarg_count > 4)
1366
- flags |= FLAG_4_GPR_ARGUMENTS;
1367
- if (struct_copy_size != 0)
1368
- flags |= FLAG_ARG_NEEDS_COPY;
1370
- if (cif->abi != FFI_LINUX64)
1372
-#ifndef __NO_FPRS__
1373
- /* Space for the FPR registers, if needed. */
1374
- if (fparg_count != 0)
1375
- bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
1378
- /* Stack space. */
1379
- if (intarg_count > NUM_GPR_ARG_REGISTERS)
1380
- bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
1381
-#ifndef __NO_FPRS__
1382
- if (fparg_count > NUM_FPR_ARG_REGISTERS)
1383
- bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
1388
-#ifndef __NO_FPRS__
1389
- /* Space for the FPR registers, if needed. */
1390
- if (fparg_count != 0)
1391
- bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
1394
- /* Stack space. */
1396
- if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0)
1397
- bytes += intarg_count * sizeof (long);
1399
- if (intarg_count > NUM_GPR_ARG_REGISTERS64)
1400
- bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
1404
- /* The stack space allocated needs to be a multiple of 16 bytes. */
1405
- bytes = (bytes + 15) & ~0xF;
1407
- /* Add in the space for the copied structures. */
1408
- bytes += struct_copy_size;
1410
- cif->flags = flags;
1411
- cif->bytes = bytes;
1417
-ffi_prep_cif_machdep (ffi_cif *cif)
1419
- cif->nfixedargs = cif->nargs;
1420
- return ffi_prep_cif_machdep_core (cif);
1424
+ffi_status FFI_HIDDEN
1425
ffi_prep_cif_machdep_var (ffi_cif *cif,
1426
- unsigned int nfixedargs,
1427
+ unsigned int nfixedargs MAYBE_UNUSED,
1428
unsigned int ntotalargs MAYBE_UNUSED)
1430
- cif->nfixedargs = nfixedargs;
1432
- if (cif->abi == FFI_LINUX64)
1433
- cif->flags |= FLAG_ARG_NEEDS_PSAVE;
1435
+ return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs);
1437
+ return ffi_prep_cif_sysv (cif);
1439
- return ffi_prep_cif_machdep_core (cif);
1442
-extern void ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
1443
- void (*fn)(void));
1444
-extern void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long,
1445
- unsigned long, unsigned long *,
1446
- void (*fn)(void));
1449
ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
1452
- * The final SYSV ABI says that structures smaller or equal 8 bytes
1453
- * are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
1456
- * We bounce-buffer SYSV small struct return values so that sysv.S
1457
- * can write r3 and r4 to memory without worrying about struct size.
1459
- * For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
1460
- * for similar reasons.
1462
+ /* The final SYSV ABI says that structures smaller or equal 8 bytes
1463
+ are returned in r3/r4. A draft ABI used by linux instead returns
1466
+ We bounce-buffer SYSV small struct return values so that sysv.S
1467
+ can write r3 and r4 to memory without worrying about struct size.
1469
+ For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
1470
+ for similar reasons. */
1471
unsigned long smst_buffer[8];
1474
@@ -1147,26 +96,11 @@
1475
else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT)
1476
ecif.rvalue = alloca (cif->rtype->size);
1481
-# ifndef __NO_FPRS__
1483
- case FFI_GCC_SYSV:
1486
- case FFI_LINUX_SOFT_FLOAT:
1487
- ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
1490
+ ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
1493
- ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
1495
+ ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
1502
/* Check for a bounce-buffered return value */
1503
if (rvalue && ecif.rvalue == smst_buffer)
1504
@@ -1175,36 +109,23 @@
1505
#ifndef __LITTLE_ENDIAN__
1506
/* The SYSV ABI returns a structure of up to 4 bytes in size
1507
left-padded in r3. */
1508
- if (cif->abi == FFI_SYSV && rsize <= 4)
1511
memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize);
1512
- /* The SYSV ABI returns a structure of up to 8 bytes in size
1513
- left-padded in r3/r4, and the ELFv2 ABI similarly returns a
1514
- structure of up to 8 bytes in size left-padded in r3. */
1515
- else if (rsize <= 8)
1516
- memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
1519
+ /* The SYSV ABI returns a structure of up to 8 bytes in size
1520
+ left-padded in r3/r4, and the ELFv2 ABI similarly returns a
1521
+ structure of up to 8 bytes in size left-padded in r3. */
1523
+ memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
1526
- memcpy (rvalue, smst_buffer, rsize);
1527
+ memcpy (rvalue, smst_buffer, rsize);
1532
-#if !defined POWERPC64 || _CALL_ELF == 2
1533
-#define MIN_CACHE_LINE_SIZE 8
1536
-flush_icache (char *wraddr, char *xaddr, int size)
1539
- for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
1540
- __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
1541
- : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
1542
- __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
1543
- : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
1549
ffi_prep_closure_loc (ffi_closure *closure,
1551
@@ -1213,593 +134,8 @@
1555
-# if _CALL_ELF == 2
1556
- unsigned int *tramp = (unsigned int *) &closure->tramp[0];
1558
- if (cif->abi != FFI_LINUX64)
1559
- return FFI_BAD_ABI;
1561
- tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
1562
- tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
1563
- tramp[2] = 0x7d8903a6; /* mtctr 12 */
1564
- tramp[3] = 0x4e800420; /* bctr */
1565
- /* 1: .quad function_addr */
1566
- /* 2: .quad context */
1567
- *(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
1568
- *(void **) &tramp[6] = codeloc;
1569
- flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
1571
- void **tramp = (void **) &closure->tramp[0];
1573
- if (cif->abi != FFI_LINUX64)
1574
- return FFI_BAD_ABI;
1575
- /* Copy function address and TOC from ffi_closure_LINUX64. */
1576
- memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
1577
- tramp[2] = codeloc;
1579
+ return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc);
1581
- unsigned int *tramp;
1583
- if (! (cif->abi == FFI_GCC_SYSV
1584
- || cif->abi == FFI_SYSV
1585
- || cif->abi == FFI_LINUX
1586
- || cif->abi == FFI_LINUX_SOFT_FLOAT))
1587
- return FFI_BAD_ABI;
1589
- tramp = (unsigned int *) &closure->tramp[0];
1590
- tramp[0] = 0x7c0802a6; /* mflr r0 */
1591
- tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
1592
- tramp[4] = 0x7d6802a6; /* mflr r11 */
1593
- tramp[5] = 0x7c0803a6; /* mtlr r0 */
1594
- tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
1595
- tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
1596
- tramp[8] = 0x7c0903a6; /* mtctr r0 */
1597
- tramp[9] = 0x4e800420; /* bctr */
1598
- *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
1599
- *(void **) &tramp[3] = codeloc; /* context */
1601
- /* Flush the icache. */
1602
- flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
1603
+ return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc);
1606
- closure->cif = cif;
1607
- closure->fun = fun;
1608
- closure->user_data = user_data;
1619
-int ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
1620
- ffi_dblfl *, unsigned long *);
1622
-/* Basically the trampoline invokes ffi_closure_SYSV, and on
1623
- * entry, r11 holds the address of the closure.
1624
- * After storing the registers that could possibly contain
1625
- * parameters to be passed into the stack frame and setting
1626
- * up space for a return value, ffi_closure_SYSV invokes the
1627
- * following helper function to do most of the work
1631
-ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
1632
- unsigned long *pgr, ffi_dblfl *pfr,
1633
- unsigned long *pst)
1635
- /* rvalue is the pointer to space for return value in closure assembly */
1636
- /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
1637
- /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
1638
- /* pst is the pointer to outgoing parameter stack in original caller */
1641
- ffi_type ** arg_types;
1643
-#ifndef __NO_FPRS__
1644
- long nf = 0; /* number of floating registers already used */
1646
- long ng = 0; /* number of general registers already used */
1648
- ffi_cif *cif = closure->cif;
1649
- unsigned size = cif->rtype->size;
1650
- unsigned short rtypenum = cif->rtype->type;
1652
- avalue = alloca (cif->nargs * sizeof (void *));
1654
- /* First translate for softfloat/nonlinux */
1655
- if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
1656
- if (rtypenum == FFI_TYPE_FLOAT)
1657
- rtypenum = FFI_TYPE_UINT32;
1658
- if (rtypenum == FFI_TYPE_DOUBLE)
1659
- rtypenum = FFI_TYPE_UINT64;
1660
- if (rtypenum == FFI_TYPE_LONGDOUBLE)
1661
- rtypenum = FFI_TYPE_UINT128;
1662
- } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
1663
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1664
- if (rtypenum == FFI_TYPE_LONGDOUBLE)
1665
- rtypenum = FFI_TYPE_STRUCT;
1670
- /* Copy the caller's structure return value address so that the closure
1671
- returns the data directly to the caller.
1672
- For FFI_SYSV the result is passed in r3/r4 if the struct size is less
1673
- or equal 8 bytes. */
1674
- if (rtypenum == FFI_TYPE_STRUCT && ((cif->abi != FFI_SYSV) || (size > 8))) {
1675
- rvalue = (void *) *pgr;
1682
- arg_types = cif->arg_types;
1684
- /* Grab the addresses of the arguments from the stack frame. */
1686
- unsigned short typenum = arg_types[i]->type;
1688
- /* We may need to handle some values depending on ABI */
1689
- if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
1690
- if (typenum == FFI_TYPE_FLOAT)
1691
- typenum = FFI_TYPE_UINT32;
1692
- if (typenum == FFI_TYPE_DOUBLE)
1693
- typenum = FFI_TYPE_UINT64;
1694
- if (typenum == FFI_TYPE_LONGDOUBLE)
1695
- typenum = FFI_TYPE_UINT128;
1696
- } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
1697
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1698
- if (typenum == FFI_TYPE_LONGDOUBLE)
1699
- typenum = FFI_TYPE_STRUCT;
1703
- switch (typenum) {
1704
-#ifndef __NO_FPRS__
1705
- case FFI_TYPE_FLOAT:
1706
- /* unfortunately float values are stored as doubles
1707
- * in the ffi_closure_SYSV code (since we don't check
1708
- * the type in that routine).
1711
- /* there are 8 64bit floating point registers */
1715
- double temp = pfr->d;
1716
- pfr->f = (float) temp;
1723
- /* FIXME? here we are really changing the values
1724
- * stored in the original calling routines outgoing
1725
- * parameter stack. This is probably a really
1726
- * naughty thing to do but...
1733
- case FFI_TYPE_DOUBLE:
1734
- /* On the outgoing stack all values are aligned to 8 */
1735
- /* there are 8 64bit floating point registers */
1745
- if (((long) pst) & 4)
1752
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1753
- case FFI_TYPE_LONGDOUBLE:
1762
- if (((long) pst) & 4)
1770
-#endif /* have FPRS */
1772
- case FFI_TYPE_UINT128:
1774
- * Test if for the whole long double, 4 gprs are available.
1775
- * otherwise the stuff ends up on the stack.
1788
- case FFI_TYPE_SINT8:
1789
- case FFI_TYPE_UINT8:
1790
-#ifndef __LITTLE_ENDIAN__
1791
- /* there are 8 gpr registers used to pass values */
1794
- avalue[i] = (char *) pgr + 3;
1800
- avalue[i] = (char *) pst + 3;
1806
- case FFI_TYPE_SINT16:
1807
- case FFI_TYPE_UINT16:
1808
-#ifndef __LITTLE_ENDIAN__
1809
- /* there are 8 gpr registers used to pass values */
1812
- avalue[i] = (char *) pgr + 2;
1818
- avalue[i] = (char *) pst + 2;
1824
- case FFI_TYPE_SINT32:
1825
- case FFI_TYPE_UINT32:
1826
- case FFI_TYPE_POINTER:
1827
- /* there are 8 gpr registers used to pass values */
1841
- case FFI_TYPE_STRUCT:
1842
- /* Structs are passed by reference. The address will appear in a
1843
- gpr if it is one of the first 8 arguments. */
1846
- avalue[i] = (void *) *pgr;
1852
- avalue[i] = (void *) *pst;
1857
- case FFI_TYPE_SINT64:
1858
- case FFI_TYPE_UINT64:
1859
- /* passing long long ints are complex, they must
1860
- * be passed in suitable register pairs such as
1861
- * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
1862
- * and if the entire pair aren't available then the outgoing
1863
- * parameter stack is used for both but an alignment of 8
1864
- * must will be kept. So we must either look in pgr
1865
- * or pst to find the correct address for this type
1872
- /* skip r4, r6, r8 as starting points */
1882
- if (((long) pst) & 4)
1898
- (closure->fun) (cif, rvalue, avalue, closure->user_data);
1900
- /* Tell ffi_closure_SYSV how to perform return type promotions.
1901
- Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
1902
- we have to tell ffi_closure_SYSV how to treat them. We combine the base
1903
- type FFI_SYSV_TYPE_SMALL_STRUCT - 1 with the size of the struct.
1904
- So a one byte struct gets the return type 16. Return type 1 to 15 are
1905
- already used and we never have a struct with size zero. That is the reason
1906
- for the subtraction of 1. See the comment in ffitarget.h about ordering.
1908
- if (cif->abi == FFI_SYSV && rtypenum == FFI_TYPE_STRUCT && size <= 8)
1909
- return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size;
1913
-int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
1914
- unsigned long *, ffi_dblfl *);
1917
-ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
1918
- unsigned long *pst, ffi_dblfl *pfr)
1920
- /* rvalue is the pointer to space for return value in closure assembly */
1921
- /* pst is the pointer to parameter save area
1922
- (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
1923
- /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
1926
- ffi_type **arg_types;
1927
- unsigned long i, avn, nfixedargs;
1929
- ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
1930
-#ifdef __STRUCT_PARM_ALIGN__
1931
- unsigned long align;
1934
- cif = closure->cif;
1935
- avalue = alloca (cif->nargs * sizeof (void *));
1937
- /* Copy the caller's structure return value address so that the
1938
- closure returns the data directly to the caller. */
1939
- if (cif->rtype->type == FFI_TYPE_STRUCT
1940
- && (cif->flags & FLAG_RETURNS_SMST) == 0)
1942
- rvalue = (void *) *pst;
1948
- nfixedargs = cif->nfixedargs;
1949
- arg_types = cif->arg_types;
1951
- /* Grab the addresses of the arguments from the stack frame. */
1954
- unsigned int elt, elnum;
1956
- switch (arg_types[i]->type)
1958
- case FFI_TYPE_SINT8:
1959
- case FFI_TYPE_UINT8:
1960
-#ifndef __LITTLE_ENDIAN__
1961
- avalue[i] = (char *) pst + 7;
1966
- case FFI_TYPE_SINT16:
1967
- case FFI_TYPE_UINT16:
1968
-#ifndef __LITTLE_ENDIAN__
1969
- avalue[i] = (char *) pst + 6;
1974
- case FFI_TYPE_SINT32:
1975
- case FFI_TYPE_UINT32:
1976
-#ifndef __LITTLE_ENDIAN__
1977
- avalue[i] = (char *) pst + 4;
1982
- case FFI_TYPE_SINT64:
1983
- case FFI_TYPE_UINT64:
1984
- case FFI_TYPE_POINTER:
1989
- case FFI_TYPE_STRUCT:
1990
-#ifdef __STRUCT_PARM_ALIGN__
1991
- align = arg_types[i]->alignment;
1992
- if (align > __STRUCT_PARM_ALIGN__)
1993
- align = __STRUCT_PARM_ALIGN__;
1995
- pst = (unsigned long *) ALIGN ((size_t) pst, align);
1999
- elt = discover_homogeneous_aggregate (arg_types[i], &elnum);
2005
- unsigned long *ul;
2011
- /* Repackage the aggregate from its parts. The
2012
- aggregate size is not greater than the space taken by
2013
- the registers so store back to the register/parameter
2015
- if (pfr + elnum <= end_pfr)
2022
- if (elt == FFI_TYPE_FLOAT)
2026
- if (pfr < end_pfr && i < nfixedargs)
2028
- *to.f = (float) pfr->d;
2036
- while (--elnum != 0);
2042
- if (pfr < end_pfr && i < nfixedargs)
2052
- while (--elnum != 0);
2057
-#ifndef __LITTLE_ENDIAN__
2058
- /* Structures with size less than eight bytes are passed
2060
- if (arg_types[i]->size < 8)
2061
- avalue[i] = (char *) pst + 8 - arg_types[i]->size;
2066
- pst += (arg_types[i]->size + 7) / 8;
2069
- case FFI_TYPE_FLOAT:
2070
- /* unfortunately float values are stored as doubles
2071
- * in the ffi_closure_LINUX64 code (since we don't check
2072
- * the type in that routine).
2075
- /* there are 13 64bit floating point registers */
2077
- if (pfr < end_pfr && i < nfixedargs)
2079
- double temp = pfr->d;
2080
- pfr->f = (float) temp;
2089
- case FFI_TYPE_DOUBLE:
2090
- /* On the outgoing stack all values are aligned to 8 */
2091
- /* there are 13 64bit floating point registers */
2093
- if (pfr < end_pfr && i < nfixedargs)
2103
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2104
- case FFI_TYPE_LONGDOUBLE:
2105
- if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
2112
- if (pfr < end_pfr && i < nfixedargs)
2114
- /* Passed partly in f13 and partly on the stack.
2115
- Move it all to the stack. */
2116
- *pst = *(unsigned long *) pfr;
2133
- (closure->fun) (cif, rvalue, avalue, closure->user_data);
2135
- /* Tell ffi_closure_LINUX64 how to perform return type promotions. */
2136
- if ((cif->flags & FLAG_RETURNS_SMST) != 0)
2138
- if ((cif->flags & FLAG_RETURNS_FP) == 0)
2139
- return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1;
2140
- else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
2141
- return FFI_V2_TYPE_DOUBLE_HOMOG;
2143
- return FFI_V2_TYPE_FLOAT_HOMOG;
2145
- return cif->rtype->type;
2147
--- a/src/libffi/src/powerpc/ffi_powerpc.h
2148
+++ b/src/libffi/src/powerpc/ffi_powerpc.h
2150
+/* -----------------------------------------------------------------------
2151
+ ffi_powerpc.h - Copyright (C) 2013 IBM
2152
+ Copyright (C) 2011 Anthony Green
2153
+ Copyright (C) 2011 Kyle Moffett
2154
+ Copyright (C) 2008 Red Hat, Inc
2155
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
2156
+ Copyright (c) 1998 Geoffrey Keating
2158
+ PowerPC Foreign Function Interface
2160
+ Permission is hereby granted, free of charge, to any person obtaining
2161
+ a copy of this software and associated documentation files (the
2162
+ ``Software''), to deal in the Software without restriction, including
2163
+ without limitation the rights to use, copy, modify, merge, publish,
2164
+ distribute, sublicense, and/or sell copies of the Software, and to
2165
+ permit persons to whom the Software is furnished to do so, subject to
2166
+ the following conditions:
2168
+ The above copyright notice and this permission notice shall be included
2169
+ in all copies or substantial portions of the Software.
2171
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
2172
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2173
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2174
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
2175
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2176
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2177
+ OTHER DEALINGS IN THE SOFTWARE.
2178
+ ----------------------------------------------------------------------- */
2181
+ /* The assembly depends on these exact flags. */
2182
+ /* These go in cr7 */
2183
+ FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
2184
+ FLAG_RETURNS_NOTHING = 1 << (31-30),
2185
+ FLAG_RETURNS_FP = 1 << (31-29),
2186
+ FLAG_RETURNS_64BITS = 1 << (31-28),
2188
+ /* This goes in cr6 */
2189
+ FLAG_RETURNS_128BITS = 1 << (31-27),
2191
+ FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */
2193
+ /* These go in cr1 */
2194
+ FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */
2195
+ FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */
2196
+ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
2197
+ FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
2198
+ FLAG_RETVAL_REFERENCE = 1 << (31- 4)
2207
+void FFI_HIDDEN ffi_closure_SYSV (void);
2208
+void FFI_HIDDEN ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
2211
+void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi);
2212
+ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *);
2213
+int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
2214
+ ffi_dblfl *, unsigned long *);
2216
+void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long, unsigned long,
2217
+ unsigned long *, void (*)(void));
2218
+void FFI_HIDDEN ffi_closure_LINUX64 (void);
2220
+void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi);
2221
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *);
2222
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int,
2224
+void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const);
2225
+int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
2226
+ unsigned long *, ffi_dblfl *);
2227
--- a/src/libffi/src/powerpc/ffitarget.h
2228
+++ b/src/libffi/src/powerpc/ffitarget.h
2230
typedef enum ffi_abi {
2238
- FFI_LINUX_SOFT_FLOAT,
2239
-# if defined(POWERPC64)
2240
- FFI_DEFAULT_ABI = FFI_LINUX64,
2241
-# elif defined(__NO_FPRS__)
2242
- FFI_DEFAULT_ABI = FFI_LINUX_SOFT_FLOAT,
2243
-# elif (__LDBL_MANT_DIG__ == 106)
2244
- FFI_DEFAULT_ABI = FFI_LINUX,
2246
- FFI_DEFAULT_ABI = FFI_GCC_SYSV,
2251
+#if defined (POWERPC_AIX)
2254
FFI_DEFAULT_ABI = FFI_AIX,
2258
-#ifdef POWERPC_DARWIN
2259
+#elif defined (POWERPC_DARWIN)
2262
FFI_DEFAULT_ABI = FFI_DARWIN,
2266
-#ifdef POWERPC_FREEBSD
2271
- FFI_LINUX_SOFT_FLOAT,
2272
- FFI_DEFAULT_ABI = FFI_SYSV,
2274
+ /* The FFI_COMPAT values are used by old code. Since libffi may be
2275
+ a shared library we have to support old values for backwards
2278
+ FFI_COMPAT_GCC_SYSV,
2279
+ FFI_COMPAT_LINUX64,
2281
+ FFI_COMPAT_LINUX_SOFT_FLOAT,
2283
+# if defined (POWERPC64)
2284
+ /* This bit, always set in new code, must not be set in any of the
2285
+ old FFI_COMPAT values that might be used for 64-bit linux. We
2286
+ only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
2287
+ all old values. */
2289
+ /* This and following bits can reuse FFI_COMPAT values. */
2290
+ FFI_LINUX_STRUCT_ALIGN = 1,
2291
+ FFI_LINUX_LONG_DOUBLE_128 = 2,
2292
+ FFI_DEFAULT_ABI = (FFI_LINUX
2293
+# ifdef __STRUCT_PARM_ALIGN__
2294
+ | FFI_LINUX_STRUCT_ALIGN
2296
+# ifdef __LONG_DOUBLE_128__
2297
+ | FFI_LINUX_LONG_DOUBLE_128
2303
+ /* This bit, always set in new code, must not be set in any of the
2304
+ old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */
2306
+ /* This and following bits can reuse FFI_COMPAT values. */
2307
+ FFI_SYSV_SOFT_FLOAT = 1,
2308
+ FFI_SYSV_STRUCT_RET = 2,
2309
+ FFI_SYSV_IBM_LONG_DOUBLE = 4,
2310
+ FFI_SYSV_LONG_DOUBLE_128 = 16,
2312
+ FFI_DEFAULT_ABI = (FFI_SYSV
2313
+# ifdef __NO_FPRS__
2314
+ | FFI_SYSV_SOFT_FLOAT
2316
+# if (defined (__SVR4_STRUCT_RETURN) \
2317
+ || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
2318
+ | FFI_SYSV_STRUCT_RET
2320
+# if __LDBL_MANT_DIG__ == 106
2321
+ | FFI_SYSV_IBM_LONG_DOUBLE
2323
+# ifdef __LONG_DOUBLE_128__
2324
+ | FFI_SYSV_LONG_DOUBLE_128
2336
/* Needed for soft-float long-double-128 support. */
2337
#define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1)
2339
-/* Needed for FFI_SYSV small structure returns.
2340
- We use two flag bits, (FLAG_SYSV_SMST_R3, FLAG_SYSV_SMST_R4) which are
2341
- defined in ffi.c, to determine the exact return type and its size. */
2342
+/* Needed for FFI_SYSV small structure returns. */
2343
#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2)
2345
/* Used by ELFv2 for homogenous structure returns. */
2346
--- a/src/libffi/src/powerpc/sysv.S
2347
+++ b/src/libffi/src/powerpc/sysv.S
2350
#include <powerpc/asm.h>
2352
-#ifndef __powerpc64__
2354
.globl ffi_prep_args_SYSV
2355
ENTRY(ffi_call_SYSV)
2363
#if defined __ELF__ && defined __linux__
2364
.section .note.GNU-stack,"",@progbits
2367
--- a/src/libffi/src/powerpc/linux64_closure.S
2368
+++ b/src/libffi/src/powerpc/linux64_closure.S
2371
.file "linux64_closure.S"
2373
-#ifdef __powerpc64__
2375
FFI_HIDDEN (ffi_closure_LINUX64)
2376
.globl ffi_closure_LINUX64
2382
-# 32 byte special reg save area + 64 byte parm save area and retval
2383
-# + 13*8 fpr save area + round to 16
2384
-# define STACKFRAME 208
2385
+# 32 byte special reg save area + 64 byte parm save area
2386
+# + 64 byte retval area + 13*8 fpr save area + round to 16
2387
+# define STACKFRAME 272
2388
# define PARMSAVE 32
2389
-# No parameter save area is needed for the call to ffi_closure_helper_LINUX64,
2390
-# so return value can start there.
2391
-# define RETVAL PARMSAVE
2392
+# define RETVAL PARMSAVE+64
2394
# 48 bytes special reg save area + 64 bytes parm save area
2395
# + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
2398
# Our caller has not allocated a parameter save area.
2399
# We need to allocate one here and use it to pass gprs to
2400
- # ffi_closure_helper_LINUX64. The return value area will do.
2401
- addi %r12, %r1, -STACKFRAME+RETVAL
2402
+ # ffi_closure_helper_LINUX64.
2403
+ addi %r12, %r1, -STACKFRAME+PARMSAVE
2406
# Save general regs into parm save area
2407
--- a/src/libffi/src/powerpc/ffi_sysv.c
2408
+++ b/src/libffi/src/powerpc/ffi_sysv.c
2410
+/* -----------------------------------------------------------------------
2411
+ ffi_sysv.c - Copyright (C) 2013 IBM
2412
+ Copyright (C) 2011 Anthony Green
2413
+ Copyright (C) 2011 Kyle Moffett
2414
+ Copyright (C) 2008 Red Hat, Inc
2415
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
2416
+ Copyright (c) 1998 Geoffrey Keating
2418
+ PowerPC Foreign Function Interface
2420
+ Permission is hereby granted, free of charge, to any person obtaining
2421
+ a copy of this software and associated documentation files (the
2422
+ ``Software''), to deal in the Software without restriction, including
2423
+ without limitation the rights to use, copy, modify, merge, publish,
2424
+ distribute, sublicense, and/or sell copies of the Software, and to
2425
+ permit persons to whom the Software is furnished to do so, subject to
2426
+ the following conditions:
2428
+ The above copyright notice and this permission notice shall be included
2429
+ in all copies or substantial portions of the Software.
2431
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
2432
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2433
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2434
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
2435
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2436
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2437
+ OTHER DEALINGS IN THE SOFTWARE.
2438
+ ----------------------------------------------------------------------- */
2443
+#include "ffi_common.h"
2444
+#include "ffi_powerpc.h"
2447
+/* About the SYSV ABI. */
2448
+#define ASM_NEEDS_REGISTERS 4
2449
+#define NUM_GPR_ARG_REGISTERS 8
2450
+#define NUM_FPR_ARG_REGISTERS 8
2453
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2454
+/* Adjust size of ffi_type_longdouble. */
2456
+ffi_prep_types_sysv (ffi_abi abi)
2458
+ if ((abi & (FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128)) == FFI_SYSV)
2460
+ ffi_type_longdouble.size = 8;
2461
+ ffi_type_longdouble.alignment = 8;
2465
+ ffi_type_longdouble.size = 16;
2466
+ ffi_type_longdouble.alignment = 16;
2471
+/* Transform long double, double and float to other types as per abi. */
2473
+translate_float (int abi, int type)
2475
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2476
+ if (type == FFI_TYPE_LONGDOUBLE
2477
+ && (abi & FFI_SYSV_LONG_DOUBLE_128) == 0)
2478
+ type = FFI_TYPE_DOUBLE;
2480
+ if ((abi & FFI_SYSV_SOFT_FLOAT) != 0)
2482
+ if (type == FFI_TYPE_FLOAT)
2483
+ type = FFI_TYPE_UINT32;
2484
+ else if (type == FFI_TYPE_DOUBLE)
2485
+ type = FFI_TYPE_UINT64;
2486
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2487
+ else if (type == FFI_TYPE_LONGDOUBLE)
2488
+ type = FFI_TYPE_UINT128;
2490
+ else if ((abi & FFI_SYSV_IBM_LONG_DOUBLE) == 0)
2492
+ if (type == FFI_TYPE_LONGDOUBLE)
2493
+ type = FFI_TYPE_STRUCT;
2499
+/* Perform machine dependent cif processing */
2501
+ffi_prep_cif_sysv_core (ffi_cif *cif)
2505
+ unsigned i, fparg_count = 0, intarg_count = 0;
2506
+ unsigned flags = cif->flags;
2507
+ unsigned struct_copy_size = 0;
2508
+ unsigned type = cif->rtype->type;
2509
+ unsigned size = cif->rtype->size;
2511
+ /* The machine-independent calculation of cif->bytes doesn't work
2512
+ for us. Redo the calculation. */
2514
+ /* Space for the frame pointer, callee's LR, and the asm's temp regs. */
2515
+ bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
2517
+ /* Space for the GPR registers. */
2518
+ bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
2520
+ /* Return value handling. The rules for SYSV are as follows:
2521
+ - 32-bit (or less) integer values are returned in gpr3;
2522
+ - Structures of size <= 4 bytes also returned in gpr3;
2523
+ - 64-bit integer values and structures between 5 and 8 bytes are returned
2525
+ - Larger structures are allocated space and a pointer is passed as
2526
+ the first argument.
2527
+ - Single/double FP values are returned in fpr1;
2528
+ - long doubles (if not equivalent to double) are returned in
2529
+ fpr1,fpr2 for Linux and as for large structs for SysV. */
2531
+ type = translate_float (cif->abi, type);
2535
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2536
+ case FFI_TYPE_LONGDOUBLE:
2537
+ flags |= FLAG_RETURNS_128BITS;
2538
+ /* Fall through. */
2540
+ case FFI_TYPE_DOUBLE:
2541
+ flags |= FLAG_RETURNS_64BITS;
2542
+ /* Fall through. */
2543
+ case FFI_TYPE_FLOAT:
2544
+ flags |= FLAG_RETURNS_FP;
2546
+ return FFI_BAD_ABI;
2550
+ case FFI_TYPE_UINT128:
2551
+ flags |= FLAG_RETURNS_128BITS;
2552
+ /* Fall through. */
2553
+ case FFI_TYPE_UINT64:
2554
+ case FFI_TYPE_SINT64:
2555
+ flags |= FLAG_RETURNS_64BITS;
2558
+ case FFI_TYPE_STRUCT:
2559
+ /* The final SYSV ABI says that structures smaller or equal 8 bytes
2560
+ are returned in r3/r4. A draft ABI used by linux instead
2561
+ returns them in memory. */
2562
+ if ((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
2564
+ flags |= FLAG_RETURNS_SMST;
2568
+ flags |= FLAG_RETVAL_REFERENCE;
2569
+ /* Fall through. */
2570
+ case FFI_TYPE_VOID:
2571
+ flags |= FLAG_RETURNS_NOTHING;
2575
+ /* Returns 32-bit integer, or similar. Nothing to do here. */
2579
+ /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
2580
+ first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
2581
+ goes on the stack. Structures and long doubles (if not equivalent
2582
+ to double) are passed as a pointer to a copy of the structure.
2583
+ Stuff on the stack needs to keep proper alignment. */
2584
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
2586
+ unsigned short typenum = (*ptr)->type;
2588
+ typenum = translate_float (cif->abi, typenum);
2592
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2593
+ case FFI_TYPE_LONGDOUBLE:
2597
+ case FFI_TYPE_DOUBLE:
2599
+ /* If this FP arg is going on the stack, it must be
2600
+ 8-byte-aligned. */
2601
+ if (fparg_count > NUM_FPR_ARG_REGISTERS
2602
+ && intarg_count >= NUM_GPR_ARG_REGISTERS
2603
+ && intarg_count % 2 != 0)
2606
+ return FFI_BAD_ABI;
2610
+ case FFI_TYPE_FLOAT:
2613
+ return FFI_BAD_ABI;
2617
+ case FFI_TYPE_UINT128:
2618
+ /* A long double in FFI_LINUX_SOFT_FLOAT can use only a set
2619
+ of four consecutive gprs. If we do not have enough, we
2620
+ have to adjust the intarg_count value. */
2621
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
2622
+ && intarg_count < NUM_GPR_ARG_REGISTERS)
2623
+ intarg_count = NUM_GPR_ARG_REGISTERS;
2624
+ intarg_count += 4;
2627
+ case FFI_TYPE_UINT64:
2628
+ case FFI_TYPE_SINT64:
2629
+ /* 'long long' arguments are passed as two words, but
2630
+ either both words must fit in registers or both go
2631
+ on the stack. If they go on the stack, they must
2632
+ be 8-byte-aligned.
2634
+ Also, only certain register pairs can be used for
2635
+ passing long long int -- specifically (r3,r4), (r5,r6),
2636
+ (r7,r8), (r9,r10). */
2637
+ if (intarg_count == NUM_GPR_ARG_REGISTERS-1
2638
+ || intarg_count % 2 != 0)
2640
+ intarg_count += 2;
2643
+ case FFI_TYPE_STRUCT:
2644
+ /* We must allocate space for a copy of these to enforce
2645
+ pass-by-value. Pad the space up to a multiple of 16
2646
+ bytes (the maximum alignment required for anything under
2648
+ struct_copy_size += ((*ptr)->size + 15) & ~0xF;
2649
+ /* Fall through (allocate space for the pointer). */
2651
+ case FFI_TYPE_POINTER:
2652
+ case FFI_TYPE_INT:
2653
+ case FFI_TYPE_UINT32:
2654
+ case FFI_TYPE_SINT32:
2655
+ case FFI_TYPE_UINT16:
2656
+ case FFI_TYPE_SINT16:
2657
+ case FFI_TYPE_UINT8:
2658
+ case FFI_TYPE_SINT8:
2659
+ /* Everything else is passed as a 4-byte word in a GPR, either
2660
+ the object itself or a pointer to it. */
2669
+ if (fparg_count != 0)
2670
+ flags |= FLAG_FP_ARGUMENTS;
2671
+ if (intarg_count > 4)
2672
+ flags |= FLAG_4_GPR_ARGUMENTS;
2673
+ if (struct_copy_size != 0)
2674
+ flags |= FLAG_ARG_NEEDS_COPY;
2676
+ /* Space for the FPR registers, if needed. */
2677
+ if (fparg_count != 0)
2678
+ bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
2680
+ /* Stack space. */
2681
+ if (intarg_count > NUM_GPR_ARG_REGISTERS)
2682
+ bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
2683
+ if (fparg_count > NUM_FPR_ARG_REGISTERS)
2684
+ bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
2686
+ /* The stack space allocated needs to be a multiple of 16 bytes. */
2687
+ bytes = (bytes + 15) & ~0xF;
2689
+ /* Add in the space for the copied structures. */
2690
+ bytes += struct_copy_size;
2692
+ cif->flags = flags;
2693
+ cif->bytes = bytes;
2698
+ffi_status FFI_HIDDEN
2699
+ffi_prep_cif_sysv (ffi_cif *cif)
2701
+ if ((cif->abi & FFI_SYSV) == 0)
2703
+ /* This call is from old code. Translate to new ABI values. */
2704
+ cif->flags |= FLAG_COMPAT;
2708
+ return FFI_BAD_ABI;
2710
+ case FFI_COMPAT_SYSV:
2711
+ cif->abi = FFI_SYSV | FFI_SYSV_STRUCT_RET | FFI_SYSV_LONG_DOUBLE_128;
2714
+ case FFI_COMPAT_GCC_SYSV:
2715
+ cif->abi = FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128;
2718
+ case FFI_COMPAT_LINUX:
2719
+ cif->abi = (FFI_SYSV | FFI_SYSV_IBM_LONG_DOUBLE
2720
+ | FFI_SYSV_LONG_DOUBLE_128);
2723
+ case FFI_COMPAT_LINUX_SOFT_FLOAT:
2724
+ cif->abi = (FFI_SYSV | FFI_SYSV_SOFT_FLOAT | FFI_SYSV_IBM_LONG_DOUBLE
2725
+ | FFI_SYSV_LONG_DOUBLE_128);
2729
+ return ffi_prep_cif_sysv_core (cif);
2732
+/* ffi_prep_args_SYSV is called by the assembly routine once stack space
2733
+ has been allocated for the function's arguments.
2735
+ The stack layout we want looks like this:
2737
+ | Return address from ffi_call_SYSV 4bytes | higher addresses
2738
+ |--------------------------------------------|
2739
+ | Previous backchain pointer 4 | stack pointer here
2740
+ |--------------------------------------------|<+ <<< on entry to
2741
+ | Saved r28-r31 4*4 | | ffi_call_SYSV
2742
+ |--------------------------------------------| |
2743
+ | GPR registers r3-r10 8*4 | | ffi_call_SYSV
2744
+ |--------------------------------------------| |
2745
+ | FPR registers f1-f8 (optional) 8*8 | |
2746
+ |--------------------------------------------| | stack |
2747
+ | Space for copied structures | | grows |
2748
+ |--------------------------------------------| | down V
2749
+ | Parameters that didn't fit in registers | |
2750
+ |--------------------------------------------| | lower addresses
2751
+ | Space for callee's LR 4 | |
2752
+ |--------------------------------------------| | stack pointer here
2753
+ | Current backchain pointer 4 |-/ during
2754
+ |--------------------------------------------| <<< ffi_call_SYSV
2759
+ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
2761
+ const unsigned bytes = ecif->cif->bytes;
2762
+ const unsigned flags = ecif->cif->flags;
2773
+ /* 'stacktop' points at the previous backchain pointer. */
2776
+ /* 'gpr_base' points at the space for gpr3, and grows upwards as
2777
+ we use GPR registers. */
2781
+#ifndef __NO_FPRS__
2782
+ /* 'fpr_base' points at the space for fpr1, and grows upwards as
2783
+ we use FPR registers. */
2788
+ /* 'copy_space' grows down as we put structures in it. It should
2789
+ stay 16-byte aligned. */
2792
+ /* 'next_arg' grows up as we put parameters in it. */
2797
+#ifndef __NO_FPRS__
2798
+ double double_tmp;
2805
+ unsigned char **uc;
2806
+ signed short **ss;
2807
+ unsigned short **us;
2808
+ unsigned int **ui;
2813
+ size_t struct_copy_size;
2814
+ unsigned gprvalue;
2816
+ stacktop.c = (char *) stack + bytes;
2817
+ gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
2819
+#ifndef __NO_FPRS__
2820
+ fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
2822
+ copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
2824
+ copy_space.c = gpr_base.c;
2826
+ next_arg.u = stack + 2;
2828
+ /* Check that everything starts aligned properly. */
2829
+ FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
2830
+ FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
2831
+ FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
2832
+ FFI_ASSERT ((bytes & 0xF) == 0);
2833
+ FFI_ASSERT (copy_space.c >= next_arg.c);
2835
+ /* Deal with return values that are actually pass-by-reference. */
2836
+ if (flags & FLAG_RETVAL_REFERENCE)
2838
+ *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
2842
+ /* Now for the arguments. */
2843
+ p_argv.v = ecif->avalue;
2844
+ for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
2846
+ i--, ptr++, p_argv.v++)
2848
+ unsigned int typenum = (*ptr)->type;
2850
+ typenum = translate_float (ecif->cif->abi, typenum);
2852
+ /* Now test the translated value */
2855
+#ifndef __NO_FPRS__
2856
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
2857
+ case FFI_TYPE_LONGDOUBLE:
2858
+ double_tmp = (*p_argv.d)[0];
2860
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
2862
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS
2863
+ && intarg_count % 2 != 0)
2868
+ *next_arg.d = double_tmp;
2870
+ double_tmp = (*p_argv.d)[1];
2871
+ *next_arg.d = double_tmp;
2876
+ *fpr_base.d++ = double_tmp;
2877
+ double_tmp = (*p_argv.d)[1];
2878
+ *fpr_base.d++ = double_tmp;
2882
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
2885
+ case FFI_TYPE_DOUBLE:
2886
+ double_tmp = **p_argv.d;
2888
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS)
2890
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS
2891
+ && intarg_count % 2 != 0)
2896
+ *next_arg.d = double_tmp;
2900
+ *fpr_base.d++ = double_tmp;
2902
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
2905
+ case FFI_TYPE_FLOAT:
2906
+ double_tmp = **p_argv.f;
2907
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS)
2909
+ *next_arg.f = (float) double_tmp;
2914
+ *fpr_base.d++ = double_tmp;
2916
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
2918
+#endif /* have FPRs */
2920
+ case FFI_TYPE_UINT128:
2921
+ /* The soft float ABI for long doubles works like this, a long double
2922
+ is passed in four consecutive GPRs if available. A maximum of 2
2923
+ long doubles can be passed in gprs. If we do not have 4 GPRs
2924
+ left, the long double is passed on the stack, 4-byte aligned. */
2926
+ unsigned int int_tmp;
2928
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
2930
+ if (intarg_count < NUM_GPR_ARG_REGISTERS)
2931
+ intarg_count = NUM_GPR_ARG_REGISTERS;
2932
+ for (ii = 0; ii < 4; ii++)
2934
+ int_tmp = (*p_argv.ui)[ii];
2935
+ *next_arg.u++ = int_tmp;
2940
+ for (ii = 0; ii < 4; ii++)
2942
+ int_tmp = (*p_argv.ui)[ii];
2943
+ *gpr_base.u++ = int_tmp;
2946
+ intarg_count += 4;
2950
+ case FFI_TYPE_UINT64:
2951
+ case FFI_TYPE_SINT64:
2952
+ if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
2954
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS)
2956
+ if (intarg_count % 2 != 0)
2961
+ *next_arg.ll = **p_argv.ll;
2966
+ /* The abi states only certain register pairs can be
2967
+ used for passing long long int specifically (r3,r4),
2968
+ (r5,r6), (r7,r8), (r9,r10). If next arg is long long
2969
+ but not correct starting register of pair then skip
2970
+ until the proper starting register. */
2971
+ if (intarg_count % 2 != 0)
2976
+ *gpr_base.ll++ = **p_argv.ll;
2978
+ intarg_count += 2;
2981
+ case FFI_TYPE_STRUCT:
2982
+ struct_copy_size = ((*ptr)->size + 15) & ~0xF;
2983
+ copy_space.c -= struct_copy_size;
2984
+ memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
2986
+ gprvalue = (unsigned long) copy_space.c;
2988
+ FFI_ASSERT (copy_space.c > next_arg.c);
2989
+ FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
2992
+ case FFI_TYPE_UINT8:
2993
+ gprvalue = **p_argv.uc;
2995
+ case FFI_TYPE_SINT8:
2996
+ gprvalue = **p_argv.sc;
2998
+ case FFI_TYPE_UINT16:
2999
+ gprvalue = **p_argv.us;
3001
+ case FFI_TYPE_SINT16:
3002
+ gprvalue = **p_argv.ss;
3005
+ case FFI_TYPE_INT:
3006
+ case FFI_TYPE_UINT32:
3007
+ case FFI_TYPE_SINT32:
3008
+ case FFI_TYPE_POINTER:
3010
+ gprvalue = **p_argv.ui;
3013
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS)
3014
+ *next_arg.u++ = gprvalue;
3016
+ *gpr_base.u++ = gprvalue;
3022
+ /* Check that we didn't overrun the stack... */
3023
+ FFI_ASSERT (copy_space.c >= next_arg.c);
3024
+ FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
3025
+ /* The assert below is testing that the number of integer arguments agrees
3026
+ with the number found in ffi_prep_cif_machdep(). However, intarg_count
3027
+ is incremented whenever we place an FP arg on the stack, so account for
3028
+ that before our assert test. */
3029
+#ifndef __NO_FPRS__
3030
+ if (fparg_count > NUM_FPR_ARG_REGISTERS)
3031
+ intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
3032
+ FFI_ASSERT (fpr_base.u
3033
+ <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
3035
+ FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
3038
+#define MIN_CACHE_LINE_SIZE 8
3041
+flush_icache (char *wraddr, char *xaddr, int size)
3044
+ for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
3045
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
3046
+ : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
3047
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
3048
+ : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
3052
+ffi_status FFI_HIDDEN
3053
+ffi_prep_closure_loc_sysv (ffi_closure *closure,
3055
+ void (*fun) (ffi_cif *, void *, void **, void *),
3059
+ unsigned int *tramp;
3061
+ if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI)
3062
+ return FFI_BAD_ABI;
3064
+ tramp = (unsigned int *) &closure->tramp[0];
3065
+ tramp[0] = 0x7c0802a6; /* mflr r0 */
3066
+ tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
3067
+ tramp[4] = 0x7d6802a6; /* mflr r11 */
3068
+ tramp[5] = 0x7c0803a6; /* mtlr r0 */
3069
+ tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
3070
+ tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
3071
+ tramp[8] = 0x7c0903a6; /* mtctr r0 */
3072
+ tramp[9] = 0x4e800420; /* bctr */
3073
+ *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
3074
+ *(void **) &tramp[3] = codeloc; /* context */
3076
+ /* Flush the icache. */
3077
+ flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
3079
+ closure->cif = cif;
3080
+ closure->fun = fun;
3081
+ closure->user_data = user_data;
3086
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
3087
+ entry, r11 holds the address of the closure.
3088
+ After storing the registers that could possibly contain
3089
+ parameters to be passed into the stack frame and setting
3090
+ up space for a return value, ffi_closure_SYSV invokes the
3091
+ following helper function to do most of the work. */
3094
+ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
3095
+ unsigned long *pgr, ffi_dblfl *pfr,
3096
+ unsigned long *pst)
3098
+ /* rvalue is the pointer to space for return value in closure assembly */
3099
+ /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
3100
+ /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
3101
+ /* pst is the pointer to outgoing parameter stack in original caller */
3104
+ ffi_type ** arg_types;
3106
+#ifndef __NO_FPRS__
3107
+ long nf = 0; /* number of floating registers already used */
3109
+ long ng = 0; /* number of general registers already used */
3111
+ ffi_cif *cif = closure->cif;
3112
+ unsigned size = cif->rtype->size;
3113
+ unsigned short rtypenum = cif->rtype->type;
3115
+ avalue = alloca (cif->nargs * sizeof (void *));
3117
+ /* First translate for softfloat/nonlinux */
3118
+ rtypenum = translate_float (cif->abi, rtypenum);
3120
+ /* Copy the caller's structure return value address so that the closure
3121
+ returns the data directly to the caller.
3122
+ For FFI_SYSV the result is passed in r3/r4 if the struct size is less
3123
+ or equal 8 bytes. */
3124
+ if (rtypenum == FFI_TYPE_STRUCT
3125
+ && !((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8))
3127
+ rvalue = (void *) *pgr;
3134
+ arg_types = cif->arg_types;
3136
+ /* Grab the addresses of the arguments from the stack frame. */
3138
+ unsigned short typenum = arg_types[i]->type;
3140
+ /* We may need to handle some values depending on ABI. */
3141
+ typenum = translate_float (cif->abi, typenum);
3145
+#ifndef __NO_FPRS__
3146
+ case FFI_TYPE_FLOAT:
3147
+ /* Unfortunately float values are stored as doubles
3148
+ in the ffi_closure_SYSV code (since we don't check
3149
+ the type in that routine). */
3150
+ if (nf < NUM_FPR_ARG_REGISTERS)
3152
+ /* FIXME? here we are really changing the values
3153
+ stored in the original calling routines outgoing
3154
+ parameter stack. This is probably a really
3155
+ naughty thing to do but... */
3156
+ double temp = pfr->d;
3157
+ pfr->f = (float) temp;
3169
+ case FFI_TYPE_DOUBLE:
3170
+ if (nf < NUM_FPR_ARG_REGISTERS)
3178
+ if (((long) pst) & 4)
3185
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3186
+ case FFI_TYPE_LONGDOUBLE:
3187
+ if (nf < NUM_FPR_ARG_REGISTERS - 1)
3195
+ if (((long) pst) & 4)
3205
+ case FFI_TYPE_UINT128:
3206
+ /* Test if for the whole long double, 4 gprs are available.
3207
+ otherwise the stuff ends up on the stack. */
3208
+ if (ng < NUM_GPR_ARG_REGISTERS - 3)
3222
+ case FFI_TYPE_SINT8:
3223
+ case FFI_TYPE_UINT8:
3224
+#ifndef __LITTLE_ENDIAN__
3225
+ if (ng < NUM_GPR_ARG_REGISTERS)
3227
+ avalue[i] = (char *) pgr + 3;
3233
+ avalue[i] = (char *) pst + 3;
3239
+ case FFI_TYPE_SINT16:
3240
+ case FFI_TYPE_UINT16:
3241
+#ifndef __LITTLE_ENDIAN__
3242
+ if (ng < NUM_GPR_ARG_REGISTERS)
3244
+ avalue[i] = (char *) pgr + 2;
3250
+ avalue[i] = (char *) pst + 2;
3256
+ case FFI_TYPE_SINT32:
3257
+ case FFI_TYPE_UINT32:
3258
+ case FFI_TYPE_POINTER:
3259
+ if (ng < NUM_GPR_ARG_REGISTERS)
3272
+ case FFI_TYPE_STRUCT:
3273
+ /* Structs are passed by reference. The address will appear in a
3274
+ gpr if it is one of the first 8 arguments. */
3275
+ if (ng < NUM_GPR_ARG_REGISTERS)
3277
+ avalue[i] = (void *) *pgr;
3283
+ avalue[i] = (void *) *pst;
3288
+ case FFI_TYPE_SINT64:
3289
+ case FFI_TYPE_UINT64:
3290
+ /* Passing long long ints are complex, they must
3291
+ be passed in suitable register pairs such as
3292
+ (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
3293
+ and if the entire pair aren't available then the outgoing
3294
+ parameter stack is used for both but an alignment of 8
3295
+ must will be kept. So we must either look in pgr
3296
+ or pst to find the correct address for this type
3298
+ if (ng < NUM_GPR_ARG_REGISTERS - 1)
3302
+ /* skip r4, r6, r8 as starting points */
3312
+ if (((long) pst) & 4)
3316
+ ng = NUM_GPR_ARG_REGISTERS;
3327
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
3329
+ /* Tell ffi_closure_SYSV how to perform return type promotions.
3330
+ Because the FFI_SYSV ABI returns the structures <= 8 bytes in
3331
+ r3/r4 we have to tell ffi_closure_SYSV how to treat them. We
3332
+ combine the base type FFI_SYSV_TYPE_SMALL_STRUCT with the size of
3333
+ the struct less one. We never have a struct with size zero.
3334
+ See the comment in ffitarget.h about ordering. */
3335
+ if (rtypenum == FFI_TYPE_STRUCT
3336
+ && (cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
3337
+ return FFI_SYSV_TYPE_SMALL_STRUCT - 1 + size;
3341
--- a/src/libffi/src/powerpc/linux64.S
3342
+++ b/src/libffi/src/powerpc/linux64.S
3344
#include <fficonfig.h>
3347
-#ifdef __powerpc64__
3349
.hidden ffi_call_LINUX64
3350
.globl ffi_call_LINUX64
3352
--- a/src/libffi/src/powerpc/ffi_linux64.c
3353
+++ b/src/libffi/src/powerpc/ffi_linux64.c
3355
+/* -----------------------------------------------------------------------
3356
+ ffi_linux64.c - Copyright (C) 2013 IBM
3357
+ Copyright (C) 2011 Anthony Green
3358
+ Copyright (C) 2011 Kyle Moffett
3359
+ Copyright (C) 2008 Red Hat, Inc
3360
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
3361
+ Copyright (c) 1998 Geoffrey Keating
3363
+ PowerPC Foreign Function Interface
3365
+ Permission is hereby granted, free of charge, to any person obtaining
3366
+ a copy of this software and associated documentation files (the
3367
+ ``Software''), to deal in the Software without restriction, including
3368
+ without limitation the rights to use, copy, modify, merge, publish,
3369
+ distribute, sublicense, and/or sell copies of the Software, and to
3370
+ permit persons to whom the Software is furnished to do so, subject to
3371
+ the following conditions:
3373
+ The above copyright notice and this permission notice shall be included
3374
+ in all copies or substantial portions of the Software.
3376
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
3377
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3378
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
3379
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
3380
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3381
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3382
+ OTHER DEALINGS IN THE SOFTWARE.
3383
+ ----------------------------------------------------------------------- */
3388
+#include "ffi_common.h"
3389
+#include "ffi_powerpc.h"
3392
+/* About the LINUX64 ABI. */
3394
+ NUM_GPR_ARG_REGISTERS64 = 8,
3395
+ NUM_FPR_ARG_REGISTERS64 = 13
3397
+enum { ASM_NEEDS_REGISTERS64 = 4 };
3400
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3401
+/* Adjust size of ffi_type_longdouble. */
3403
+ffi_prep_types_linux64 (ffi_abi abi)
3405
+ if ((abi & (FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128)) == FFI_LINUX)
3407
+ ffi_type_longdouble.size = 8;
3408
+ ffi_type_longdouble.alignment = 8;
3412
+ ffi_type_longdouble.size = 16;
3413
+ ffi_type_longdouble.alignment = 16;
3420
+static unsigned int
3421
+discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
3425
+ case FFI_TYPE_FLOAT:
3426
+ case FFI_TYPE_DOUBLE:
3428
+ return (int) t->type;
3430
+ case FFI_TYPE_STRUCT:;
3432
+ unsigned int base_elt = 0, total_elnum = 0;
3433
+ ffi_type **el = t->elements;
3436
+ unsigned int el_elt, el_elnum = 0;
3437
+ el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
3439
+ || (base_elt && base_elt != el_elt))
3441
+ base_elt = el_elt;
3442
+ total_elnum += el_elnum;
3443
+ if (total_elnum > 8)
3447
+ *elnum = total_elnum;
3458
+/* Perform machine dependent cif processing */
3460
+ffi_prep_cif_linux64_core (ffi_cif *cif)
3464
+ unsigned i, fparg_count = 0, intarg_count = 0;
3465
+ unsigned flags = cif->flags;
3467
+ unsigned int elt, elnum;
3470
+#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE
3471
+ /* If compiled without long double support.. */
3472
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
3473
+ return FFI_BAD_ABI;
3476
+ /* The machine-independent calculation of cif->bytes doesn't work
3477
+ for us. Redo the calculation. */
3479
+ /* Space for backchain, CR, LR, TOC and the asm's temp regs. */
3480
+ bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long);
3482
+ /* Space for the general registers. */
3483
+ bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long);
3485
+ /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
3487
+ bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
3489
+ /* Space for the mandatory parm save area and general registers. */
3490
+ bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
3493
+ /* Return value handling. */
3494
+ switch (cif->rtype->type)
3496
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3497
+ case FFI_TYPE_LONGDOUBLE:
3498
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
3499
+ flags |= FLAG_RETURNS_128BITS;
3500
+ /* Fall through. */
3502
+ case FFI_TYPE_DOUBLE:
3503
+ flags |= FLAG_RETURNS_64BITS;
3504
+ /* Fall through. */
3505
+ case FFI_TYPE_FLOAT:
3506
+ flags |= FLAG_RETURNS_FP;
3509
+ case FFI_TYPE_UINT128:
3510
+ flags |= FLAG_RETURNS_128BITS;
3511
+ /* Fall through. */
3512
+ case FFI_TYPE_UINT64:
3513
+ case FFI_TYPE_SINT64:
3514
+ flags |= FLAG_RETURNS_64BITS;
3517
+ case FFI_TYPE_STRUCT:
3519
+ elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
3522
+ if (elt == FFI_TYPE_DOUBLE)
3523
+ flags |= FLAG_RETURNS_64BITS;
3524
+ flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
3527
+ if (cif->rtype->size <= 16)
3529
+ flags |= FLAG_RETURNS_SMST;
3534
+ flags |= FLAG_RETVAL_REFERENCE;
3535
+ /* Fall through. */
3536
+ case FFI_TYPE_VOID:
3537
+ flags |= FLAG_RETURNS_NOTHING;
3541
+ /* Returns 32-bit integer, or similar. Nothing to do here. */
3545
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
3547
+ unsigned int align;
3549
+ switch ((*ptr)->type)
3551
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3552
+ case FFI_TYPE_LONGDOUBLE:
3553
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
3558
+ /* Fall through. */
3560
+ case FFI_TYPE_DOUBLE:
3561
+ case FFI_TYPE_FLOAT:
3564
+ if (fparg_count > NUM_FPR_ARG_REGISTERS64)
3565
+ flags |= FLAG_ARG_NEEDS_PSAVE;
3568
+ case FFI_TYPE_STRUCT:
3569
+ if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
3571
+ align = (*ptr)->alignment;
3574
+ align = align / 8;
3576
+ intarg_count = ALIGN (intarg_count, align);
3578
+ intarg_count += ((*ptr)->size + 7) / 8;
3580
+ elt = discover_homogeneous_aggregate (*ptr, &elnum);
3583
+ fparg_count += elnum;
3584
+ if (fparg_count > NUM_FPR_ARG_REGISTERS64)
3585
+ flags |= FLAG_ARG_NEEDS_PSAVE;
3590
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
3591
+ flags |= FLAG_ARG_NEEDS_PSAVE;
3595
+ case FFI_TYPE_POINTER:
3596
+ case FFI_TYPE_UINT64:
3597
+ case FFI_TYPE_SINT64:
3598
+ case FFI_TYPE_INT:
3599
+ case FFI_TYPE_UINT32:
3600
+ case FFI_TYPE_SINT32:
3601
+ case FFI_TYPE_UINT16:
3602
+ case FFI_TYPE_SINT16:
3603
+ case FFI_TYPE_UINT8:
3604
+ case FFI_TYPE_SINT8:
3605
+ /* Everything else is passed as a 8-byte word in a GPR, either
3606
+ the object itself or a pointer to it. */
3608
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
3609
+ flags |= FLAG_ARG_NEEDS_PSAVE;
3616
+ if (fparg_count != 0)
3617
+ flags |= FLAG_FP_ARGUMENTS;
3618
+ if (intarg_count > 4)
3619
+ flags |= FLAG_4_GPR_ARGUMENTS;
3621
+ /* Space for the FPR registers, if needed. */
3622
+ if (fparg_count != 0)
3623
+ bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
3625
+ /* Stack space. */
3627
+ if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0)
3628
+ bytes += intarg_count * sizeof (long);
3630
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
3631
+ bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
3634
+ /* The stack space allocated needs to be a multiple of 16 bytes. */
3635
+ bytes = (bytes + 15) & ~0xF;
3637
+ cif->flags = flags;
3638
+ cif->bytes = bytes;
3643
+ffi_status FFI_HIDDEN
3644
+ffi_prep_cif_linux64 (ffi_cif *cif)
3646
+ if ((cif->abi & FFI_LINUX) != 0)
3647
+ cif->nfixedargs = cif->nargs;
3649
+ else if (cif->abi == FFI_COMPAT_LINUX64)
3651
+ /* This call is from old code. Don't touch cif->nfixedargs
3652
+ since old code will be using a smaller cif. */
3653
+ cif->flags |= FLAG_COMPAT;
3654
+ /* Translate to new abi value. */
3655
+ cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
3659
+ return FFI_BAD_ABI;
3660
+ return ffi_prep_cif_linux64_core (cif);
3663
+ffi_status FFI_HIDDEN
3664
+ffi_prep_cif_linux64_var (ffi_cif *cif,
3665
+ unsigned int nfixedargs,
3666
+ unsigned int ntotalargs MAYBE_UNUSED)
3668
+ if ((cif->abi & FFI_LINUX) != 0)
3669
+ cif->nfixedargs = nfixedargs;
3671
+ else if (cif->abi == FFI_COMPAT_LINUX64)
3673
+ /* This call is from old code. Don't touch cif->nfixedargs
3674
+ since old code will be using a smaller cif. */
3675
+ cif->flags |= FLAG_COMPAT;
3676
+ /* Translate to new abi value. */
3677
+ cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
3681
+ return FFI_BAD_ABI;
3683
+ cif->flags |= FLAG_ARG_NEEDS_PSAVE;
3685
+ return ffi_prep_cif_linux64_core (cif);
3689
+/* ffi_prep_args64 is called by the assembly routine once stack space
3690
+ has been allocated for the function's arguments.
3692
+ The stack layout we want looks like this:
3694
+ | Ret addr from ffi_call_LINUX64 8bytes | higher addresses
3695
+ |--------------------------------------------|
3696
+ | CR save area 8bytes |
3697
+ |--------------------------------------------|
3698
+ | Previous backchain pointer 8 | stack pointer here
3699
+ |--------------------------------------------|<+ <<< on entry to
3700
+ | Saved r28-r31 4*8 | | ffi_call_LINUX64
3701
+ |--------------------------------------------| |
3702
+ | GPR registers r3-r10 8*8 | |
3703
+ |--------------------------------------------| |
3704
+ | FPR registers f1-f13 (optional) 13*8 | |
3705
+ |--------------------------------------------| |
3706
+ | Parameter save area | |
3707
+ |--------------------------------------------| |
3708
+ | TOC save area 8 | |
3709
+ |--------------------------------------------| | stack |
3710
+ | Linker doubleword 8 | | grows |
3711
+ |--------------------------------------------| | down V
3712
+ | Compiler doubleword 8 | |
3713
+ |--------------------------------------------| | lower addresses
3714
+ | Space for callee's LR 8 | |
3715
+ |--------------------------------------------| |
3716
+ | CR save area 8 | |
3717
+ |--------------------------------------------| | stack pointer here
3718
+ | Current backchain pointer 8 |-/ during
3719
+ |--------------------------------------------| <<< ffi_call_LINUX64
3724
+ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
3726
+ const unsigned long bytes = ecif->cif->bytes;
3727
+ const unsigned long flags = ecif->cif->flags;
3732
+ unsigned long *ul;
3738
+ /* 'stacktop' points at the previous backchain pointer. */
3741
+ /* 'next_arg' points at the space for gpr3, and grows upwards as
3742
+ we use GPR registers, then continues at rest. */
3748
+ /* 'fpr_base' points at the space for fpr3, and grows upwards as
3749
+ we use FPR registers. */
3751
+ unsigned int fparg_count;
3753
+ unsigned int i, words, nargs, nfixedargs;
3755
+ double double_tmp;
3761
+ unsigned char **uc;
3762
+ signed short **ss;
3763
+ unsigned short **us;
3765
+ unsigned int **ui;
3766
+ unsigned long **ul;
3770
+ unsigned long gprvalue;
3771
+ unsigned long align;
3773
+ stacktop.c = (char *) stack + bytes;
3774
+ gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
3775
+ gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
3777
+ rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64;
3779
+ rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
3781
+ fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
3783
+ next_arg.ul = gpr_base.ul;
3785
+ /* Check that everything starts aligned properly. */
3786
+ FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
3787
+ FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
3788
+ FFI_ASSERT ((bytes & 0xF) == 0);
3790
+ /* Deal with return values that are actually pass-by-reference. */
3791
+ if (flags & FLAG_RETVAL_REFERENCE)
3792
+ *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
3794
+ /* Now for the arguments. */
3795
+ p_argv.v = ecif->avalue;
3796
+ nargs = ecif->cif->nargs;
3798
+ nfixedargs = (unsigned) -1;
3799
+ if ((flags & FLAG_COMPAT) == 0)
3801
+ nfixedargs = ecif->cif->nfixedargs;
3802
+ for (ptr = ecif->cif->arg_types, i = 0;
3804
+ i++, ptr++, p_argv.v++)
3807
+ unsigned int elt, elnum;
3810
+ switch ((*ptr)->type)
3812
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3813
+ case FFI_TYPE_LONGDOUBLE:
3814
+ if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
3816
+ double_tmp = (*p_argv.d)[0];
3817
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3819
+ *fpr_base.d++ = double_tmp;
3820
+# if _CALL_ELF != 2
3821
+ if ((flags & FLAG_COMPAT) != 0)
3822
+ *next_arg.d = double_tmp;
3826
+ *next_arg.d = double_tmp;
3827
+ if (++next_arg.ul == gpr_end.ul)
3828
+ next_arg.ul = rest.ul;
3830
+ double_tmp = (*p_argv.d)[1];
3831
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3833
+ *fpr_base.d++ = double_tmp;
3834
+# if _CALL_ELF != 2
3835
+ if ((flags & FLAG_COMPAT) != 0)
3836
+ *next_arg.d = double_tmp;
3840
+ *next_arg.d = double_tmp;
3841
+ if (++next_arg.ul == gpr_end.ul)
3842
+ next_arg.ul = rest.ul;
3844
+ FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
3845
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3848
+ /* Fall through. */
3850
+ case FFI_TYPE_DOUBLE:
3851
+ double_tmp = **p_argv.d;
3852
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3854
+ *fpr_base.d++ = double_tmp;
3856
+ if ((flags & FLAG_COMPAT) != 0)
3857
+ *next_arg.d = double_tmp;
3861
+ *next_arg.d = double_tmp;
3862
+ if (++next_arg.ul == gpr_end.ul)
3863
+ next_arg.ul = rest.ul;
3865
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3868
+ case FFI_TYPE_FLOAT:
3869
+ double_tmp = **p_argv.f;
3870
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3872
+ *fpr_base.d++ = double_tmp;
3874
+ if ((flags & FLAG_COMPAT) != 0)
3875
+ *next_arg.f = (float) double_tmp;
3879
+ *next_arg.f = (float) double_tmp;
3880
+ if (++next_arg.ul == gpr_end.ul)
3881
+ next_arg.ul = rest.ul;
3883
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3886
+ case FFI_TYPE_STRUCT:
3887
+ if ((ecif->cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
3889
+ align = (*ptr)->alignment;
3893
+ next_arg.p = ALIGN (next_arg.p, align);
3896
+ elt = discover_homogeneous_aggregate (*ptr, &elnum);
3905
+ arg.v = *p_argv.v;
3906
+ if (elt == FFI_TYPE_FLOAT)
3910
+ double_tmp = *arg.f++;
3911
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64
3912
+ && i < nfixedargs)
3913
+ *fpr_base.d++ = double_tmp;
3915
+ *next_arg.f = (float) double_tmp;
3916
+ if (++next_arg.f == gpr_end.f)
3917
+ next_arg.f = rest.f;
3920
+ while (--elnum != 0);
3921
+ if ((next_arg.p & 3) != 0)
3923
+ if (++next_arg.f == gpr_end.f)
3924
+ next_arg.f = rest.f;
3930
+ double_tmp = *arg.d++;
3931
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3932
+ *fpr_base.d++ = double_tmp;
3934
+ *next_arg.d = double_tmp;
3935
+ if (++next_arg.d == gpr_end.d)
3936
+ next_arg.d = rest.d;
3939
+ while (--elnum != 0);
3944
+ words = ((*ptr)->size + 7) / 8;
3945
+ if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
3947
+ size_t first = gpr_end.c - next_arg.c;
3948
+ memcpy (next_arg.c, *p_argv.c, first);
3949
+ memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
3950
+ next_arg.c = rest.c + words * 8 - first;
3954
+ char *where = next_arg.c;
3956
+#ifndef __LITTLE_ENDIAN__
3957
+ /* Structures with size less than eight bytes are passed
3959
+ if ((*ptr)->size < 8)
3960
+ where += 8 - (*ptr)->size;
3962
+ memcpy (where, *p_argv.c, (*ptr)->size);
3963
+ next_arg.ul += words;
3964
+ if (next_arg.ul == gpr_end.ul)
3965
+ next_arg.ul = rest.ul;
3970
+ case FFI_TYPE_UINT8:
3971
+ gprvalue = **p_argv.uc;
3973
+ case FFI_TYPE_SINT8:
3974
+ gprvalue = **p_argv.sc;
3976
+ case FFI_TYPE_UINT16:
3977
+ gprvalue = **p_argv.us;
3979
+ case FFI_TYPE_SINT16:
3980
+ gprvalue = **p_argv.ss;
3982
+ case FFI_TYPE_UINT32:
3983
+ gprvalue = **p_argv.ui;
3985
+ case FFI_TYPE_INT:
3986
+ case FFI_TYPE_SINT32:
3987
+ gprvalue = **p_argv.si;
3990
+ case FFI_TYPE_UINT64:
3991
+ case FFI_TYPE_SINT64:
3992
+ case FFI_TYPE_POINTER:
3993
+ gprvalue = **p_argv.ul;
3995
+ *next_arg.ul++ = gprvalue;
3996
+ if (next_arg.ul == gpr_end.ul)
3997
+ next_arg.ul = rest.ul;
4002
+ FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
4003
+ || (next_arg.ul >= gpr_base.ul
4004
+ && next_arg.ul <= gpr_base.ul + 4));
4009
+#define MIN_CACHE_LINE_SIZE 8
4012
+flush_icache (char *wraddr, char *xaddr, int size)
4015
+ for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
4016
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
4017
+ : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
4018
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
4019
+ : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
4025
+ffi_prep_closure_loc_linux64 (ffi_closure *closure,
4027
+ void (*fun) (ffi_cif *, void *, void **, void *),
4032
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
4034
+ if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
4035
+ return FFI_BAD_ABI;
4037
+ tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
4038
+ tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
4039
+ tramp[2] = 0x7d8903a6; /* mtctr 12 */
4040
+ tramp[3] = 0x4e800420; /* bctr */
4041
+ /* 1: .quad function_addr */
4042
+ /* 2: .quad context */
4043
+ *(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
4044
+ *(void **) &tramp[6] = codeloc;
4045
+ flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
4047
+ void **tramp = (void **) &closure->tramp[0];
4049
+ if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
4050
+ return FFI_BAD_ABI;
4052
+ /* Copy function address and TOC from ffi_closure_LINUX64. */
4053
+ memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
4054
+ tramp[2] = codeloc;
4057
+ closure->cif = cif;
4058
+ closure->fun = fun;
4059
+ closure->user_data = user_data;
4066
+ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
4067
+ unsigned long *pst, ffi_dblfl *pfr)
4069
+ /* rvalue is the pointer to space for return value in closure assembly */
4070
+ /* pst is the pointer to parameter save area
4071
+ (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
4072
+ /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
4075
+ ffi_type **arg_types;
4076
+ unsigned long i, avn, nfixedargs;
4078
+ ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
4079
+ unsigned long align;
4081
+ cif = closure->cif;
4082
+ avalue = alloca (cif->nargs * sizeof (void *));
4084
+ /* Copy the caller's structure return value address so that the
4085
+ closure returns the data directly to the caller. */
4086
+ if (cif->rtype->type == FFI_TYPE_STRUCT
4087
+ && (cif->flags & FLAG_RETURNS_SMST) == 0)
4089
+ rvalue = (void *) *pst;
4096
+ nfixedargs = (unsigned) -1;
4097
+ if ((cif->flags & FLAG_COMPAT) == 0)
4099
+ nfixedargs = cif->nfixedargs;
4100
+ arg_types = cif->arg_types;
4102
+ /* Grab the addresses of the arguments from the stack frame. */
4105
+ unsigned int elt, elnum;
4107
+ switch (arg_types[i]->type)
4109
+ case FFI_TYPE_SINT8:
4110
+ case FFI_TYPE_UINT8:
4111
+#ifndef __LITTLE_ENDIAN__
4112
+ avalue[i] = (char *) pst + 7;
4117
+ case FFI_TYPE_SINT16:
4118
+ case FFI_TYPE_UINT16:
4119
+#ifndef __LITTLE_ENDIAN__
4120
+ avalue[i] = (char *) pst + 6;
4125
+ case FFI_TYPE_SINT32:
4126
+ case FFI_TYPE_UINT32:
4127
+#ifndef __LITTLE_ENDIAN__
4128
+ avalue[i] = (char *) pst + 4;
4133
+ case FFI_TYPE_SINT64:
4134
+ case FFI_TYPE_UINT64:
4135
+ case FFI_TYPE_POINTER:
4140
+ case FFI_TYPE_STRUCT:
4141
+ if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
4143
+ align = arg_types[i]->alignment;
4147
+ pst = (unsigned long *) ALIGN ((size_t) pst, align);
4151
+ elt = discover_homogeneous_aggregate (arg_types[i], &elnum);
4157
+ unsigned long *ul;
4163
+ /* Repackage the aggregate from its parts. The
4164
+ aggregate size is not greater than the space taken by
4165
+ the registers so store back to the register/parameter
4167
+ if (pfr + elnum <= end_pfr)
4174
+ if (elt == FFI_TYPE_FLOAT)
4178
+ if (pfr < end_pfr && i < nfixedargs)
4180
+ *to.f = (float) pfr->d;
4188
+ while (--elnum != 0);
4194
+ if (pfr < end_pfr && i < nfixedargs)
4204
+ while (--elnum != 0);
4209
+#ifndef __LITTLE_ENDIAN__
4210
+ /* Structures with size less than eight bytes are passed
4212
+ if (arg_types[i]->size < 8)
4213
+ avalue[i] = (char *) pst + 8 - arg_types[i]->size;
4218
+ pst += (arg_types[i]->size + 7) / 8;
4221
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
4222
+ case FFI_TYPE_LONGDOUBLE:
4223
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
4225
+ if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
4232
+ if (pfr < end_pfr && i < nfixedargs)
4234
+ /* Passed partly in f13 and partly on the stack.
4235
+ Move it all to the stack. */
4236
+ *pst = *(unsigned long *) pfr;
4244
+ /* Fall through. */
4246
+ case FFI_TYPE_DOUBLE:
4247
+ /* On the outgoing stack all values are aligned to 8 */
4248
+ /* there are 13 64bit floating point registers */
4250
+ if (pfr < end_pfr && i < nfixedargs)
4260
+ case FFI_TYPE_FLOAT:
4261
+ if (pfr < end_pfr && i < nfixedargs)
4263
+ /* Float values are stored as doubles in the
4264
+ ffi_closure_LINUX64 code. Fix them here. */
4265
+ pfr->f = (float) pfr->d;
4282
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
4284
+ /* Tell ffi_closure_LINUX64 how to perform return type promotions. */
4285
+ if ((cif->flags & FLAG_RETURNS_SMST) != 0)
4287
+ if ((cif->flags & FLAG_RETURNS_FP) == 0)
4288
+ return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1;
4289
+ else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
4290
+ return FFI_V2_TYPE_DOUBLE_HOMOG;
4292
+ return FFI_V2_TYPE_FLOAT_HOMOG;
4294
+ return cif->rtype->type;
4297
--- a/src/libffi/src/powerpc/ppc_closure.S
4298
+++ b/src/libffi/src/powerpc/ppc_closure.S
4301
.file "ppc_closure.S"
4303
-#ifndef __powerpc64__
4306
ENTRY(ffi_closure_SYSV)
4314
#if defined __ELF__ && defined __linux__
4315
.section .note.GNU-stack,"",@progbits
4318
--- a/src/libffi/src/types.c
4319
+++ b/src/libffi/src/types.c
4324
+#define FFI_NONCONST_TYPEDEF(name, type, id) \
4325
+struct struct_align_##name { \
4329
+ffi_type ffi_type_##name = { \
4331
+ offsetof(struct struct_align_##name, x), \
4335
/* Size and alignment are fake here. They must not be 0. */
4336
const ffi_type ffi_type_void = {
4337
1, 1, FFI_TYPE_VOID, NULL
4340
const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
4341
#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
4342
+# if HAVE_LONG_DOUBLE_VARIANT
4343
+FFI_NONCONST_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
4345
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
4348
--- a/src/libffi/testsuite/Makefile.in
4349
+++ b/src/libffi/testsuite/Makefile.in
4353
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
4354
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
4356
INSTALL_DATA = @INSTALL_DATA@
4357
INSTALL_PROGRAM = @INSTALL_PROGRAM@