OSDN Git Service

2009-06-12 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / nested_struct.c
index adce7ba..8aa527e 100644 (file)
@@ -68,10 +68,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];
@@ -79,12 +77,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;
@@ -143,12 +135,12 @@ 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))
-            (pcl))(e_dbl, f_dbl, g_dbl);
+            (code))(e_dbl, f_dbl, g_dbl);
   /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 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));