Issue #20160: Merged fix from 3.3.

This commit is contained in:
Vinay Sajip 2016-08-05 21:43:25 +01:00
commit a0b2568627
3 changed files with 65 additions and 2 deletions

View file

@ -26,6 +26,24 @@ _testfunc_cbk_reg_double(double a, double b, double c, double d, double e,
return func(a*a, b*b, c*c, d*d, e*e);
}
/*
* This structure should be the same as in test_callbacks.py and the
* method test_callback_large_struct. See issues 17310 and 20160: the
* structure must be larger than 8 bytes long.
*/
typedef struct {
unsigned long first;
unsigned long second;
unsigned long third;
} Test;
EXPORT(void)
_testfunc_cbk_large_struct(Test in, void (*func)(Test))
{
func(in);
}
EXPORT(void)testfunc_array(int values[4])
{
printf("testfunc_array %d %d %d %d\n",

View file

@ -359,7 +359,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
argp += sizeof(void *);
}
p_argv = avalue;
@ -370,13 +370,23 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
/* Align if necessary */
if ((sizeof(char *) - 1) & (size_t) argp) {
argp = (char *) ALIGN(argp, sizeof(char*));
argp = (char *) ALIGN(argp, sizeof(char*));
}
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
#ifdef _WIN64
if (z > 8) {
/* On Win64, if a single argument takes more than 8 bytes,
* then it is always passed by reference.
*/
*p_argv = *((void**) argp);
z = 8;
}
else
#endif
*p_argv = (void*) argp;
p_argv++;