use ffi_closure_alloc instead of stack-based closure
This commit is contained in:
@@ -20,19 +20,11 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp,
|
||||
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[3];
|
||||
ffi_type* arg_types[3];
|
||||
|
||||
#ifdef USING_MMAP
|
||||
pcl = allocate_mmap(sizeof(ffi_closure));
|
||||
#else
|
||||
pcl = &cl;
|
||||
#endif
|
||||
|
||||
char* format = "%.1f\n";
|
||||
double doubleArg = 7;
|
||||
ffi_arg res = 0;
|
||||
@@ -53,9 +45,9 @@ int main (void)
|
||||
printf("res: %d\n", (int) res);
|
||||
// { dg-output "\nres: 4" }
|
||||
|
||||
CHECK(ffi_prep_closure(pcl, &cif, cls_double_va_fn, NULL) == FFI_OK);
|
||||
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK);
|
||||
|
||||
res = ((int(*)(char*, double))(pcl))(format, doubleArg);
|
||||
res = ((int(*)(char*, double))(code))(format, doubleArg);
|
||||
// { dg-output "\n7.0" }
|
||||
printf("res: %d\n", (int) res);
|
||||
// { dg-output "\nres: 4" }
|
||||
|
||||
Reference in New Issue
Block a user