sparc: Define FFI_TARGET_SPECIFIC_VARIADIC for v9
This is a port of http://gcc.gnu.org/viewcvs?rev=207763&root=gcc&view=rev aka GCC PR libffi/60073, to the rewritten Sparc codebase. Supposedly, we should have seen failures with the existing libffi.call/cls_double_va.c testcase, but I hadn't. Perhaps a gcc newer than 4.6.3 is required to see that...
This commit is contained in:
@@ -159,8 +159,8 @@ ffi_struct_float_copy (int size_mask, void *vd, void *vi, void *vf)
|
|||||||
|
|
||||||
/* Perform machine dependent cif processing */
|
/* Perform machine dependent cif processing */
|
||||||
|
|
||||||
ffi_status FFI_HIDDEN
|
static ffi_status
|
||||||
ffi_prep_cif_machdep(ffi_cif *cif)
|
ffi_prep_cif_machdep_core(ffi_cif *cif)
|
||||||
{
|
{
|
||||||
ffi_type *rtype = cif->rtype;
|
ffi_type *rtype = cif->rtype;
|
||||||
int rtt = rtype->type;
|
int rtt = rtype->type;
|
||||||
@@ -304,6 +304,20 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|||||||
return FFI_OK;
|
return FFI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ffi_status FFI_HIDDEN
|
||||||
|
ffi_prep_cif_machdep(ffi_cif *cif)
|
||||||
|
{
|
||||||
|
cif->nfixedargs = cif->nargs;
|
||||||
|
return ffi_prep_cif_machdep_core(cif);
|
||||||
|
}
|
||||||
|
|
||||||
|
ffi_status FFI_HIDDEN
|
||||||
|
ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned nfixedargs, unsigned ntotalargs)
|
||||||
|
{
|
||||||
|
cif->nfixedargs = nfixedargs;
|
||||||
|
return ffi_prep_cif_machdep_core(cif);
|
||||||
|
}
|
||||||
|
|
||||||
extern void ffi_call_v9(ffi_cif *cif, void (*fn)(void), void *rvalue,
|
extern void ffi_call_v9(ffi_cif *cif, void (*fn)(void), void *rvalue,
|
||||||
void **avalue, size_t bytes, void *closure) FFI_HIDDEN;
|
void **avalue, size_t bytes, void *closure) FFI_HIDDEN;
|
||||||
|
|
||||||
@@ -495,11 +509,12 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif,
|
|||||||
{
|
{
|
||||||
ffi_type **arg_types;
|
ffi_type **arg_types;
|
||||||
void **avalue;
|
void **avalue;
|
||||||
int i, argn, argx, nargs, flags;
|
int i, argn, argx, nargs, flags, nfixedargs;
|
||||||
|
|
||||||
arg_types = cif->arg_types;
|
arg_types = cif->arg_types;
|
||||||
nargs = cif->nargs;
|
nargs = cif->nargs;
|
||||||
flags = cif->flags;
|
flags = cif->flags;
|
||||||
|
nfixedargs = cif->nfixedargs;
|
||||||
|
|
||||||
avalue = alloca(nargs * sizeof(void *));
|
avalue = alloca(nargs * sizeof(void *));
|
||||||
|
|
||||||
@@ -517,6 +532,7 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif,
|
|||||||
/* Grab the addresses of the arguments from the stack frame. */
|
/* Grab the addresses of the arguments from the stack frame. */
|
||||||
for (i = 0; i < nargs; i++, argn = argx)
|
for (i = 0; i < nargs; i++, argn = argx)
|
||||||
{
|
{
|
||||||
|
int named = i < nfixedargs;
|
||||||
ffi_type *ty = arg_types[i];
|
ffi_type *ty = arg_types[i];
|
||||||
void *a = &gpr[argn];
|
void *a = &gpr[argn];
|
||||||
size_t z;
|
size_t z;
|
||||||
@@ -532,7 +548,7 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
argx = argn + ALIGN (z, 8) / 8;
|
argx = argn + ALIGN (z, 8) / 8;
|
||||||
if (argn < 16)
|
if (named && argn < 16)
|
||||||
{
|
{
|
||||||
int size_mask = ffi_struct_float_mask (ty, 0);
|
int size_mask = ffi_struct_float_mask (ty, 0);
|
||||||
int argn_mask = (0xffff00 >> argn) & 0xff00;
|
int argn_mask = (0xffff00 >> argn) & 0xff00;
|
||||||
@@ -546,15 +562,15 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif,
|
|||||||
|
|
||||||
case FFI_TYPE_LONGDOUBLE:
|
case FFI_TYPE_LONGDOUBLE:
|
||||||
argn = ALIGN (argn, 2);
|
argn = ALIGN (argn, 2);
|
||||||
a = (argn < 16 ? fpr : gpr) + argn;
|
a = (named && argn < 16 ? fpr : gpr) + argn;
|
||||||
argx = argn + 2;
|
argx = argn + 2;
|
||||||
break;
|
break;
|
||||||
case FFI_TYPE_DOUBLE:
|
case FFI_TYPE_DOUBLE:
|
||||||
if (argn <= 16)
|
if (named && argn < 16)
|
||||||
a = fpr + argn;
|
a = fpr + argn;
|
||||||
break;
|
break;
|
||||||
case FFI_TYPE_FLOAT:
|
case FFI_TYPE_FLOAT:
|
||||||
if (argn <= 16)
|
if (named && argn < 16)
|
||||||
a = fpr + argn;
|
a = fpr + argn;
|
||||||
a += 4;
|
a += 4;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -57,8 +57,13 @@ typedef enum ffi_abi {
|
|||||||
} ffi_abi;
|
} ffi_abi;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
|
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 1
|
||||||
#define FFI_TARGET_HAS_COMPLEX_TYPE
|
#define FFI_TARGET_HAS_COMPLEX_TYPE 1
|
||||||
|
|
||||||
|
#ifdef SPARC64
|
||||||
|
# define FFI_TARGET_SPECIFIC_VARIADIC 1
|
||||||
|
# define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ---- Definitions for closures ----------------------------------------- */
|
/* ---- Definitions for closures ----------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user