OSDN Git Service

2009-06-12 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / nested_struct10.c
index 8d9aba2..d6a718b 100644 (file)
@@ -58,10 +58,8 @@ B_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[4];
   ffi_type* cls_struct_fields[3];
   ffi_type* cls_struct_fields1[4];
@@ -69,12 +67,6 @@ int main (void)
   ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
   ffi_type* dbl_arg_types[4];
 
-#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;
@@ -129,9 +121,9 @@ int main (void)
   CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
   CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
 
-  CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+  CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
 
-  res_dbl = ((B(*)(A, B, C))(pcl))(e_dbl, f_dbl, g_dbl);
+  res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
   /* { dg-output "\n1 7 12 127 99 255 2 9: 270 242 143" } */
   CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d));
   CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));