* 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.
This commit is contained in:
Gregory P. Smith 2013-04-30 00:03:01 -07:00
parent e9d0633d36
commit 5dc268ed26
16 changed files with 418 additions and 231 deletions

View File

@ -3,6 +3,7 @@
sysv.S - Copyright (c) 2012 Alan Hourihane
Copyright (c) 1998, 2012 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc.
Copyright (c) 2012 Thorsten Glaser
m68k Foreign Function Interface
@ -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)

View File

@ -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 */

View File

@ -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)
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. */

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
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;
}

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
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:
/* 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();

View File

@ -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

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
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__ */

View File

@ -1,6 +1,7 @@
/* -----------------------------------------------------------------------
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__

View File

@ -13,37 +13,39 @@ 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_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/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 \
@ -72,14 +74,21 @@ 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/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

View File

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.3 from Makefile.am.
# Makefile.in generated by automake 1.12.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -15,6 +14,23 @@
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -37,7 +53,19 @@ target_triplet = @target@
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_cc_maxopt.m4 \
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
$(top_srcdir)/m4/ax_configure_args.m4 \
$(top_srcdir)/m4/ax_enable_builddir.m4 \
$(top_srcdir)/m4/ax_gcc_archflag.m4 \
$(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@ -47,6 +75,11 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
DEJATOOL = $(PACKAGE)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -114,6 +147,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PRTDIAG = @PRTDIAG@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@ -134,6 +168,7 @@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_enable_builddir_sed = @ax_enable_builddir_sed@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@ -169,6 +204,7 @@ psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
@ -191,36 +227,37 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
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_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/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 \
@ -249,17 +286,23 @@ 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/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
all: all-am
@ -306,6 +349,8 @@ TAGS:
ctags: CTAGS
CTAGS:
cscope cscopelist:
check-DEJAGNU: site.exp
srcdir='$(srcdir)'; export srcdir; \
@ -316,11 +361,11 @@ check-DEJAGNU: site.exp
if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
then :; else exit_status=1; fi; \
done; \
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
else echo "WARNING: could not find 'runtest'" 1>&2; :;\
fi; \
exit $$exit_status
site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@echo 'Making a new site.exp file...'
@echo 'Making a new site.exp file ...'
@echo '## these variables are automatically generated by make ##' >site.tmp
@echo '# Do not edit here. If you wish to override these values' >>site.tmp
@echo '# edit the last section' >>site.tmp

View File

@ -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]
}

View File

@ -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* } } */

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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)
{