use ffi_closure_alloc instead of stack-based closure
This commit is contained in:
@@ -72,10 +72,8 @@ cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
||||
int main (void)
|
||||
{
|
||||
ffi_cif cif;
|
||||
#ifndef USING_MMAP
|
||||
static ffi_closure cl;
|
||||
#endif
|
||||
ffi_closure *pcl;
|
||||
void *code;
|
||||
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
|
||||
void* args_dbl[5];
|
||||
ffi_type* cls_struct_fields[5];
|
||||
ffi_type* cls_struct_fields1[5];
|
||||
@@ -83,12 +81,6 @@ int main (void)
|
||||
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
|
||||
ffi_type* dbl_arg_types[5];
|
||||
|
||||
#ifdef USING_MMAP
|
||||
pcl = allocate_mmap (sizeof(ffi_closure));
|
||||
#else
|
||||
pcl = &cl;
|
||||
#endif
|
||||
|
||||
cls_struct_type.size = 0;
|
||||
cls_struct_type.alignment = 0;
|
||||
cls_struct_type.type = FFI_TYPE_STRUCT;
|
||||
@@ -150,13 +142,13 @@ int main (void)
|
||||
CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
|
||||
CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
|
||||
|
||||
CHECK(ffi_prep_closure(pcl, &cif, cls_struct_combined_gn, NULL) == FFI_OK);
|
||||
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
|
||||
|
||||
res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1,
|
||||
cls_struct_16byte2,
|
||||
cls_struct_combined,
|
||||
cls_struct_16byte1))
|
||||
(pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
|
||||
(code))(e_dbl, f_dbl, g_dbl, h_dbl);
|
||||
/* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */
|
||||
CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
|
||||
CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
|
||||
|
||||
Reference in New Issue
Block a user