Commit 5dc268ed authored by Gregory P. Smith's avatar Gregory P. Smith

* Fix remaining bits of issue 17192 for 3.3 - these changes

  were missing from a messed up merge during the libffi 3.0.13
  import.  the diffs from upstream libffi 3.0.13 are now small.
parent e9d0633d
......@@ -2,9 +2,10 @@
sysv.S - Copyright (c) 2012 Alan Hourihane
Copyright (c) 1998, 2012 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc.
m68k Foreign Function Interface
Copyright (c) 2008 Red Hat, Inc.
Copyright (c) 2012 Thorsten Glaser
m68k Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
......@@ -168,8 +169,28 @@ retstruct1:
retstruct2:
btst #7,%d2
jbeq noretval
jbeq retsint8
move.w %d0,(%a1)
jbra epilogue
retsint8:
btst #8,%d2
jbeq retsint16
| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
ext.w %d0
ext.l %d0
#else
extb.l %d0
#endif
move.l %d0,(%a1)
jbra epilogue
retsint16:
btst #9,%d2
jbeq noretval
ext.l %d0
move.l %d0,(%a1)
noretval:
epilogue:
......@@ -201,8 +222,10 @@ CALLFUNC(ffi_closure_SYSV):
lsr.l #1,%d0
jne 1f
jcc .Lcls_epilogue
| CIF_FLAGS_INT
move.l -12(%fp),%d0
.Lcls_epilogue:
| no CIF_FLAGS_*
unlk %fp
rts
1:
......@@ -210,6 +233,7 @@ CALLFUNC(ffi_closure_SYSV):
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_float
| CIF_FLAGS_DINT
move.l (%a0)+,%d0
move.l (%a0),%d1
jra .Lcls_epilogue
......@@ -224,6 +248,7 @@ CALLFUNC(ffi_closure_SYSV):
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_ldouble
| CIF_FLAGS_DOUBLE
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d (%a0),%fp0
#else
......@@ -242,17 +267,37 @@ CALLFUNC(ffi_closure_SYSV):
jra .Lcls_epilogue
1:
lsr.l #2,%d0
jne .Lcls_ret_struct2
jne 1f
jcs .Lcls_ret_struct1
| CIF_FLAGS_POINTER
move.l (%a0),%a0
move.l %a0,%d0
jra .Lcls_epilogue
.Lcls_ret_struct1:
move.b (%a0),%d0
jra .Lcls_epilogue
.Lcls_ret_struct2:
1:
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_sint8
| CIF_FLAGS_STRUCT2
move.w (%a0),%d0
jra .Lcls_epilogue
.Lcls_ret_sint8:
move.l (%a0),%d0
| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
ext.w %d0
ext.l %d0
#else
extb.l %d0
#endif
jra .Lcls_epilogue
1:
| CIF_FLAGS_SINT16
move.l (%a0),%d0
ext.l %d0
jra .Lcls_epilogue
CFI_ENDPROC()
.size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
......
......@@ -670,9 +670,16 @@ ffi_prep_closure_loc (ffi_closure *closure,
if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT)
return FFI_BAD_ABI;
fn = ffi_closure_O32;
#else /* FFI_MIPS_N32 */
if (cif->abi != FFI_N32 && cif->abi != FFI_N64)
#else
#if _MIPS_SIM ==_ABIN32
if (cif->abi != FFI_N32
&& cif->abi != FFI_N32_SOFT_FLOAT)
return FFI_BAD_ABI;
#else
if (cif->abi != FFI_N64
&& cif->abi != FFI_N64_SOFT_FLOAT)
return FFI_BAD_ABI;
#endif
fn = ffi_closure_N32;
#endif /* FFI_MIPS_O32 */
......
......@@ -48,6 +48,11 @@ enum {
FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
FLAG_SYSV_SMST_R4 = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte
structs. */
FLAG_SYSV_SMST_R3 = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte
structs. */
FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
#ifndef __NO_FPRS__
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
......@@ -367,7 +372,13 @@ ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
/* Check that we didn't overrun the stack... */
FFI_ASSERT (copy_space.c >= next_arg.c);
FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
/* The assert below is testing that the number of integer arguments agrees
with the number found in ffi_prep_cif_machdep(). However, intarg_count
is incremeneted whenever we place an FP arg on the stack, so account for
that before our assert test. */
#ifndef __NO_FPRS__
if (fparg_count > NUM_FPR_ARG_REGISTERS)
intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
FFI_ASSERT (fpr_base.u
<= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
#endif
......@@ -664,9 +675,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
switch (type)
{
#ifndef __NO_FPRS__
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
flags |= FLAG_RETURNS_128BITS;
/* Fall through. */
#endif
case FFI_TYPE_DOUBLE:
flags |= FLAG_RETURNS_64BITS;
/* Fall through. */
......@@ -684,18 +697,35 @@ ffi_prep_cif_machdep (ffi_cif *cif)
break;
case FFI_TYPE_STRUCT:
/*
* The final SYSV ABI says that structures smaller or equal 8 bytes
* are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
* in memory.
*
* NOTE: The assembly code can safely assume that it just needs to
* store both r3 and r4 into a 8-byte word-aligned buffer, as
* we allocate a temporary buffer in ffi_call() if this flag is
* set.
*/
if (cif->abi == FFI_SYSV && size <= 8)
flags |= FLAG_RETURNS_SMST;
if (cif->abi == FFI_SYSV)
{
/* The final SYSV ABI says that structures smaller or equal 8 bytes
are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
in memory. */
/* Treat structs with size <= 8 bytes. */
if (size <= 8)
{
flags |= FLAG_RETURNS_SMST;
/* These structs are returned in r3. We pack the type and the
precalculated shift value (needed in the sysv.S) into flags.
The same applies for the structs returned in r3/r4. */
if (size <= 4)
{
flags |= FLAG_SYSV_SMST_R3;
flags |= 8 * (4 - size) << 8;
break;
}
/* These structs are returned in r3 and r4. See above. */
if (size <= 8)
{
flags |= FLAG_SYSV_SMST_R3 | FLAG_SYSV_SMST_R4;
flags |= 8 * (8 - size) << 8;
break;
}
}
}
intarg_count++;
flags |= FLAG_RETVAL_REFERENCE;
/* Fall through. */
......
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2011 Anthony Green
ffi.c - Copyright (c) 2011, 2013 Anthony Green
Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc.
SPARC Foreign Function Interface
......@@ -376,6 +376,10 @@ extern int ffi_call_v8(void *, extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)(void));
#endif
#ifndef __GNUC__
void ffi_flush_icache (void *, size_t);
#endif
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
......@@ -417,7 +421,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
/* behind "call", so we alloc some executable space for it. */
/* l7 is used, we need to make sure v8.S doesn't use %l7. */
unsigned int *call_struct = NULL;
ffi_closure_alloc(32, &call_struct);
ffi_closure_alloc(32, (void **)&call_struct);
if (call_struct)
{
unsigned long f = (unsigned long)fn;
......@@ -432,10 +436,14 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
call_struct[5] = 0x01000000; /* nop */
call_struct[6] = 0x81c7e008; /* ret */
call_struct[7] = 0xbe100017; /* mov %l7, %i7 */
#ifdef __GNUC__
asm volatile ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : :
"r" (call_struct) : "memory");
/* SPARC v8 requires 5 instructions for flush to be visible */
asm volatile ("nop; nop; nop; nop; nop");
#else
ffi_flush_icache (call_struct, 32);
#endif
ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes,
cif->flags, rvalue, call_struct);
ffi_closure_free(call_struct);
......@@ -513,6 +521,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
closure->user_data = user_data;
/* Flush the Icache. closure is 8 bytes aligned. */
#ifdef __GNUC__
#ifdef SPARC64
asm volatile ("flush %0; flush %0+8" : : "r" (closure) : "memory");
#else
......@@ -520,6 +529,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
/* SPARC v8 requires 5 instructions for flush to be visible */
asm volatile ("nop; nop; nop; nop; nop");
#endif
#else
ffi_flush_icache (closure, 16);
#endif
return FFI_OK;
}
......
/* -----------------------------------------------------------------------
ffi64.c - Copyright (c) 20011 Anthony Green
ffi64.c - Copyright (c) 2013 The Written Word, Inc.
Copyright (c) 2011 Anthony Green
Copyright (c) 2008, 2010 Red Hat, Inc.
Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
......@@ -37,17 +38,29 @@
#define MAX_GPR_REGS 6
#define MAX_SSE_REGS 8
#ifdef __INTEL_COMPILER
#if defined(__INTEL_COMPILER)
#define UINT128 __m128
#else
#if defined(__SUNPRO_C)
#include <sunmedia_types.h>
#define UINT128 __m128i
#else
#define UINT128 __int128_t
#endif
#endif
union big_int_union
{
UINT32 i32;
UINT64 i64;
UINT128 i128;
};
struct register_args
{
/* Registers for argument passing. */
UINT64 gpr[MAX_GPR_REGS];
UINT128 sse[MAX_SSE_REGS];
union big_int_union sse[MAX_SSE_REGS];
};
extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
......@@ -471,16 +484,33 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
case X86_64_INTEGER_CLASS:
case X86_64_INTEGERSI_CLASS:
reg_args->gpr[gprcount] = 0;
memcpy (&reg_args->gpr[gprcount], a, size < 8 ? size : 8);
/* Sign-extend integer arguments passed in general
purpose registers, to cope with the fact that
LLVM incorrectly assumes that this will be done
(the x86-64 PS ABI does not specify this). */
switch (arg_types[i]->type)
{
case FFI_TYPE_SINT8:
*(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
break;
case FFI_TYPE_SINT16:
*(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
break;
case FFI_TYPE_SINT32:
*(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
break;
default:
reg_args->gpr[gprcount] = 0;
memcpy (&reg_args->gpr[gprcount], a, size < 8 ? size : 8);
}
gprcount++;
break;
case X86_64_SSE_CLASS:
case X86_64_SSEDF_CLASS:
reg_args->sse[ssecount++] = *(UINT64 *) a;
reg_args->sse[ssecount++].i64 = *(UINT64 *) a;
break;
case X86_64_SSESF_CLASS:
reg_args->sse[ssecount++] = *(UINT32 *) a;
reg_args->sse[ssecount++].i32 = *(UINT32 *) a;
break;
default:
abort();
......
......@@ -61,8 +61,9 @@ typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#endif
#else
#if defined __x86_64__ && !defined __LP64__
#if defined __x86_64__ && defined __ILP32__
#define FFI_SIZEOF_ARG 8
#define FFI_SIZEOF_JAVA_RAW 4
typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#else
......
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008, 2010 Red Hat, Inc.
sysv.S - Copyright (c) 2013 The Written Word, Inc.
- Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
X86 Foreign Function Interface
......@@ -181,9 +182,19 @@ ffi_closure_SYSV:
leal -24(%ebp), %edx
movl %edx, -12(%ebp) /* resp */
leal 8(%ebp), %edx
#ifdef __SUNPRO_C
/* The SUNPRO compiler doesn't support GCC's regparm function
attribute, so we have to pass all three arguments to
ffi_closure_SYSV_inner on the stack. */
movl %edx, 8(%esp) /* args = __builtin_dwarf_cfa () */
leal -12(%ebp), %edx
movl %edx, 4(%esp) /* &resp */
movl %eax, (%esp) /* closure */
#else
movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
leal -12(%ebp), %edx
movl %edx, (%esp) /* &resp */
#endif
#if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
call ffi_closure_SYSV_inner
#else
......@@ -328,6 +339,9 @@ ffi_closure_raw_SYSV:
.size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
#endif
#if defined __GNUC__
/* Only emit dwarf unwind info when building with GNU toolchain. */
#if defined __PIC__
# if defined __sun__ && defined __svr4__
/* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22
......@@ -459,6 +473,7 @@ ffi_closure_raw_SYSV:
.align 4
.LEFDE3:
#endif
#endif
#endif /* ifndef __x86_64__ */
......
/* -----------------------------------------------------------------------
unix64.S - Copyright (c) 2002 Bo Thorsen <bo@suse.de>
Copyright (c) 2008 Red Hat, Inc
unix64.S - Copyright (c) 2013 The Written Word, Inc.
- Copyright (c) 2008 Red Hat, Inc
- Copyright (c) 2002 Bo Thorsen <bo@suse.de>
x86-64 Foreign Function Interface
......@@ -324,6 +325,9 @@ ffi_closure_unix64:
.LUW9:
.size ffi_closure_unix64,.-ffi_closure_unix64
#ifdef __GNUC__
/* Only emit DWARF unwind info when building with the GNU toolchain. */
#ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
.section .eh_frame,"a",@unwind
#else
......@@ -419,6 +423,8 @@ ffi_closure_unix64:
.align 8
.LEFDE3:
#endif /* __GNUC__ */
#endif /* __x86_64__ */
#if defined __ELF__ && defined __linux__
......
......@@ -13,73 +13,82 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
AM_RUNTESTFLAGS =
EXTRA_DEJAGNU_SITE_CONFIG=../local.exp
CLEANFILES = *.exe core* *.log *.sum
EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \
libffi.call/cls_align_longdouble_split.c libffi.call/closure_loc_fn0.c \
libffi.call/cls_schar.c libffi.call/closure_fn1.c \
libffi.call/many2_win32.c libffi.call/return_ul.c \
libffi.call/cls_align_double.c libffi.call/return_fl2.c \
libffi.call/cls_1_1byte.c libffi.call/cls_64byte.c \
libffi.call/nested_struct7.c libffi.call/cls_align_sint32.c \
libffi.call/nested_struct2.c libffi.call/ffitest.h \
libffi.call/nested_struct4.c libffi.call/cls_multi_ushort.c \
libffi.call/struct3.c libffi.call/cls_3byte1.c \
libffi.call/cls_16byte.c libffi.call/struct8.c \
libffi.call/nested_struct8.c libffi.call/cls_multi_sshort.c \
libffi.call/cls_3byte2.c libffi.call/fastthis2_win32.c \
libffi.call/cls_pointer.c libffi.call/err_bad_typedef.c \
libffi.call/cls_4_1byte.c libffi.call/cls_9byte2.c \
libffi.call/cls_multi_schar.c libffi.call/stret_medium2.c \
libffi.call/cls_5_1_byte.c libffi.call/call.exp \
libffi.call/cls_double.c libffi.call/cls_align_sint16.c \
libffi.call/cls_uint.c libffi.call/return_ll1.c \
libffi.call/nested_struct3.c libffi.call/cls_20byte1.c \
libffi.call/closure_fn4.c libffi.call/cls_uchar.c \
libffi.call/struct2.c libffi.call/cls_7byte.c libffi.call/strlen.c \
libffi.call/many.c libffi.call/testclosure.c libffi.call/return_fl.c \
libffi.call/struct5.c libffi.call/cls_12byte.c \
libffi.call/cls_multi_sshortchar.c \
libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \
libffi.call/return_fl3.c libffi.call/stret_medium.c \
libffi.call/nested_struct6.c libffi.call/a.out \
libffi.call/closure_fn3.c libffi.call/float3.c libffi.call/many2.c \
libffi.call/closure_stdcall.c libffi.call/cls_align_uint16.c \
libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \
libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \
libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \
libffi.call/cls_sshort.c libffi.call/many_win32.c \
libffi.call/nested_struct.c libffi.call/cls_20byte.c \
libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \
libffi.call/return_uc.c libffi.call/closure_thiscall.c \
libffi.call/cls_18byte.c libffi.call/cls_8byte.c \
libffi.call/promotion.c libffi.call/struct1_win32.c \
libffi.call/return_dbl.c libffi.call/cls_24byte.c \
libffi.call/struct4.c libffi.call/cls_6byte.c \
libffi.call/cls_align_uint32.c libffi.call/float.c \
libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \
libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \
libffi.call/cls_align_float.c libffi.call/return_fl1.c \
libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
libffi.call/fastthis1_win32.c libffi.call/cls_align_sint64.c \
libffi.call/stret_large2.c libffi.call/return_sl.c \
libffi.call/closure_fn0.c libffi.call/cls_5byte.c \
libffi.call/cls_2byte.c libffi.call/float2.c \
libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \
libffi.call/stret_large.c libffi.call/cls_ulonglong.c \
libffi.call/cls_ushort.c libffi.call/nested_struct1.c \
libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \
libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \
libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \
libffi.call/struct1.c libffi.call/nested_struct9.c \
libffi.call/huge_struct.c libffi.call/problem1.c libffi.call/float4.c \
libffi.call/fastthis3_win32.c libffi.call/return_ldl.c \
libffi.call/strlen2_win32.c libffi.call/closure_fn5.c \
libffi.call/struct2_win32.c libffi.call/struct6.c \
libffi.call/return_ll.c libffi.call/struct9.c libffi.call/return_sc.c \
libffi.call/struct7.c libffi.call/cls_align_uint64.c \
libffi.call/cls_4byte.c libffi.call/strlen_win32.c \
libffi.call/cls_6_1_byte.c libffi.call/cls_7_1_byte.c \
libffi.special/unwindtest.cc libffi.special/special.exp \
libffi.special/unwindtest_ffi_call.cc libffi.special/ffitestcxx.h \
lib/wrapper.exp lib/target-libpath.exp lib/libffi.exp
EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \
libffi.call/cls_align_longdouble_split.c \
libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \
libffi.call/closure_fn1.c libffi.call/many2_win32.c \
libffi.call/return_ul.c libffi.call/cls_align_double.c \
libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \
libffi.call/cls_64byte.c libffi.call/nested_struct7.c \
libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \
libffi.call/ffitest.h libffi.call/nested_struct4.c \
libffi.call/cls_multi_ushort.c libffi.call/struct3.c \
libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \
libffi.call/struct8.c libffi.call/nested_struct8.c \
libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \
libffi.call/fastthis2_win32.c libffi.call/cls_pointer.c \
libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \
libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \
libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \
libffi.call/call.exp libffi.call/cls_double.c \
libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \
libffi.call/return_ll1.c libffi.call/nested_struct3.c \
libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \
libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \
libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \
libffi.call/return_fl.c libffi.call/struct5.c \
libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \
libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \
libffi.call/return_fl3.c libffi.call/stret_medium.c \
libffi.call/nested_struct6.c libffi.call/closure_fn3.c \
libffi.call/float3.c libffi.call/many2.c \
libffi.call/closure_stdcall.c libffi.call/cls_align_uint16.c \
libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \
libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \
libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \
libffi.call/cls_sshort.c libffi.call/many_win32.c \
libffi.call/nested_struct.c libffi.call/cls_20byte.c \
libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \
libffi.call/return_uc.c libffi.call/closure_thiscall.c \
libffi.call/cls_18byte.c libffi.call/cls_8byte.c \
libffi.call/promotion.c libffi.call/struct1_win32.c \
libffi.call/return_dbl.c libffi.call/cls_24byte.c \
libffi.call/struct4.c libffi.call/cls_6byte.c \
libffi.call/cls_align_uint32.c libffi.call/float.c \
libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \
libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \
libffi.call/cls_align_float.c libffi.call/return_fl1.c \
libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
libffi.call/fastthis1_win32.c libffi.call/cls_align_sint64.c \
libffi.call/stret_large2.c libffi.call/return_sl.c \
libffi.call/closure_fn0.c libffi.call/cls_5byte.c \
libffi.call/cls_2byte.c libffi.call/float2.c \
libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \
libffi.call/stret_large.c libffi.call/cls_ulonglong.c \
libffi.call/cls_ushort.c libffi.call/nested_struct1.c \
libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \
libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \
libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \
libffi.call/struct1.c libffi.call/nested_struct9.c \
libffi.call/huge_struct.c libffi.call/problem1.c \
libffi.call/float4.c libffi.call/fastthis3_win32.c \
libffi.call/return_ldl.c libffi.call/strlen2_win32.c \
libffi.call/closure_fn5.c libffi.call/struct2_win32.c \
libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \
libffi.call/return_sc.c libffi.call/struct7.c \
libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \
libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \
libffi.call/cls_7_1_byte.c libffi.special/unwindtest.cc \
libffi.special/special.exp libffi.special/unwindtest_ffi_call.cc \
libffi.special/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \
lib/libffi.exp libffi.call/cls_struct_va1.c \
libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \
libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \
libffi.call/nested_struct11.c libffi.call/uninitialized.c \
libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \
libffi.call/va_struct3.c
......@@ -101,9 +101,17 @@ proc libffi-init { args } {
global tool_root_dir
global ld_library_path
global using_gcc
set blddirffi [pwd]/..
verbose "libffi $blddirffi"
# Are we building with GCC?
set tmp [grep ../config.status "GCC='yes'"]
if { [string match $tmp "GCC='yes'"] } {
set using_gcc "yes"
set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
if {$gccdir != ""} {
set gccdir [file dirname $gccdir]
......@@ -127,6 +135,13 @@ proc libffi-init { args } {
}
}
}
} else {
set using_gcc "no"
}
# add the library path for libffi.
append ld_library_path ":${blddirffi}/.libs"
......@@ -203,6 +218,10 @@ proc libffi_target_compile { source dest type options } {
lappend options "libs= -lffi"
if { [string match "aarch64*-*-linux*" $target_triplet] } {
lappend options "libs= -lpthread"
}
verbose "options: $options"
return [target_compile $source $dest $type $options]
}
......
......@@ -5,7 +5,9 @@
Originator: Blake Chaffin */
/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
/* { dg-do run { xfail arm*-*-* strongarm*-*-* xscale*-*-* } } */
/* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have
remove the xfail for arm*-*-* below, until we know more. */
/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
......
......@@ -15,7 +15,7 @@
#define MAX_ARGS 256
#define CHECK(x) !(x) ? abort() : 0
#define CHECK(x) !(x) ? (abort(), 1) : 0
/* Define __UNUSED__ that also other compilers than gcc can run the tests. */
#undef __UNUSED__
......@@ -127,44 +127,6 @@
#define PRId64 "I64d"
#endif
#ifdef USING_MMAP
static inline void *
allocate_mmap (size_t size)
{
void *page;
#if defined (HAVE_MMAP_DEV_ZERO)
static int dev_zero_fd = -1;
#endif
#ifdef HAVE_MMAP_DEV_ZERO
if (dev_zero_fd == -1)
{
dev_zero_fd = open ("/dev/zero", O_RDONLY);
if (dev_zero_fd == -1)
{
perror ("open /dev/zero: %m");
exit (1);
}
}
#endif
#ifdef HAVE_MMAP_ANON
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
#ifdef HAVE_MMAP_DEV_ZERO
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE, dev_zero_fd, 0);
#endif
if (page == (void *) MAP_FAILED)
{
perror ("virtual memory exhausted");
exit (1);
}
return page;
}
#ifndef PRIuPTR
#define PRIuPTR "u"
#endif
......@@ -56,9 +56,9 @@ int main (void)
* different. */
/* Call it statically and then via ffi */
resfp=float_va_fn(0,2.0);
// { dg-output "0: 2.0 : total: 2.0" }
/* { dg-output "0: 2.0 : total: 2.0" } */
printf("compiled: %.1f\n", resfp);
// { dg-output "\ncompiled: 2.0" }
/* { dg-output "\ncompiled: 2.0" } */
arg_types[0] = &ffi_type_uint;
arg_types[1] = &ffi_type_double;
......@@ -71,16 +71,16 @@ int main (void)
values[0] = &firstarg;
values[1] = &doubles[0];
ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values);
// { dg-output "\n0: 2.0 : total: 2.0" }
/* { dg-output "\n0: 2.0 : total: 2.0" } */
printf("ffi: %.1f\n", resfp);
// { dg-output "\nffi: 2.0" }
/* { dg-output "\nffi: 2.0" } */
/* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */
/* Call it statically and then via ffi */
resfp=float_va_fn(2,2.0,3.0,4.0);
// { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" }
/* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */
printf("compiled: %.1f\n", resfp);
// { dg-output "\ncompiled: 11.0" }
/* { dg-output "\ncompiled: 11.0" } */
arg_types[0] = &ffi_type_uint;
arg_types[1] = &ffi_type_double;
......@@ -99,9 +99,9 @@ int main (void)
values[2] = &doubles[1];
values[3] = &doubles[2];
ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values);
// { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" }
/* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */
printf("ffi: %.1f\n", resfp);
// { dg-output "\nffi: 11.0" }
/* { dg-output "\nffi: 11.0" } */
exit(0);
}
......@@ -8,6 +8,7 @@
/* { dg-excess-errors "" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
/* { dg-options -Wformat=0 { target moxie*-*-elf } } */
/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
......@@ -295,7 +296,7 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 50, &ret_struct_type, argTypes) == FFI_OK);
ffi_call(&cif, FFI_FN(test_large_fn), &retVal, argValues);
// { dg-output "1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
/* { dg-output "1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
"%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
"%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
......@@ -308,7 +309,7 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
// { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
/* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_large_fn, NULL, code) == FFI_OK);
......@@ -323,7 +324,7 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
ui8, si8);
// { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
/* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
"%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
"%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
......@@ -336,7 +337,7 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
// { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
/* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
return 0;
}
......@@ -12,7 +12,10 @@
typedef unsigned char u8;
__attribute__((noinline)) uint8_t
#ifdef __GNUC__
__attribute__((noinline))
#endif
uint8_t
foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
uint8_t e, uint8_t f, uint8_t g)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment