use ffi_closure_alloc instead of stack-based closure
This commit is contained in:
@@ -36,21 +36,13 @@ typedef signed char (*test_type)(signed char, signed char);
|
||||
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[3];
|
||||
ffi_type * cl_arg_types[3];
|
||||
ffi_arg res_call;
|
||||
signed char a, b, res_closure;
|
||||
|
||||
#ifdef USING_MMAP
|
||||
pcl = allocate_mmap (sizeof(ffi_closure));
|
||||
#else
|
||||
pcl = &cl;
|
||||
#endif
|
||||
|
||||
a = 2;
|
||||
b = 125;
|
||||
|
||||
@@ -71,9 +63,9 @@ int main (void)
|
||||
printf("res: %d\n", (signed char)res_call);
|
||||
/* { dg-output "\nres: 127" } */
|
||||
|
||||
CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
|
||||
CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
|
||||
|
||||
res_closure = (*((test_type)pcl))(2, 125);
|
||||
res_closure = (*((test_type)code))(2, 125);
|
||||
/* { dg-output "\n2 125: 127" } */
|
||||
printf("res: %d\n", res_closure);
|
||||
/* { dg-output "\nres: 127" } */
|
||||
|
||||
Reference in New Issue
Block a user