OSDN Git Service

2009-06-12 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.special / unwindtest.cc
index a3d8037..7238716 100644 (file)
@@ -6,6 +6,7 @@
 
 /* { dg-do run } */
 #include "ffitestcxx.h"
+#include <stdint.h>
 
 void
 closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
@@ -27,7 +28,7 @@ void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp,
       (int)(*(double*)args[8]) + (int)*(int *)args[9] +
       (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
       (int)*(int *)args[12] + (int)(*(int *)args[13]) +
-      (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
+      (int)(*(int *)args[14]) + *(int *)args[15] + (int)(intptr_t)userdata;
 
     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
           (int)*(float *)args[0], (int)(*(float *)args[1]),
@@ -38,7 +39,7 @@ void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp,
           (int)(*(int *)args[10]), (int)(*(float *)args[11]),
           (int)*(int *)args[12], (int)(*(int *)args[13]),
           (int)(*(int *)args[14]), *(int *)args[15],
-          (int)(long)userdata, (int)*(ffi_arg*)resp);
+          (int)(intptr_t)userdata, (int)*(ffi_arg*)resp);
 
     throw (int)*(ffi_arg*)resp;
 }
@@ -50,27 +51,20 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short,
 int main (void)
 {
   ffi_cif cif;
-#ifndef USING_MMAP
-  static ffi_closure cl;
-#endif
-  ffi_closure *pcl;
+  void *code;
+  ffi_closure *pcl = (ffi_closure *)ffi_closure_alloc(sizeof(ffi_closure), &code);
   ffi_type * cl_arg_types[17];
-#ifdef USING_MMAP
-  pcl = (ffi_closure *) allocate_mmap (sizeof(ffi_closure));
-#else
-  pcl = &cl;
-#endif
 
   {
     cl_arg_types[1] = NULL;
 
     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0,
                       &ffi_type_void, cl_arg_types) == FFI_OK);
-    CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn, NULL) == FFI_OK);
+    CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn, NULL, code) == FFI_OK);
 
     try
       {
-       (*((closure_test_type)(pcl)))();
+       (*((closure_test_type)(code)))();
       } catch (int exception_code)
       {
        CHECK(exception_code == 9);
@@ -104,11 +98,11 @@ int main (void)
       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
                         &ffi_type_sint, cl_arg_types) == FFI_OK);
 
-      CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn1,
-                            (void *) 3 /* userdata */)  == FFI_OK);
+      CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
+                                 (void *) 3 /* userdata */, code)  == FFI_OK);
       try
        {
-         (*((closure_test_type1)pcl))
+         (*((closure_test_type1)code))
            (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
             19, 21, 1);
          /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */