OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libffi/] [testsuite/] [libffi.special/] [unwindtest.cc] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Area:        ffi_closure, unwind info
2
   Purpose:     Check if the unwind information is passed correctly.
3
   Limitations: none.
4
   PR:          none.
5
   Originator:  Jeff Sturm <jsturm@one-point.com>  */
6
 
7
/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
8
#include "ffitestcxx.h"
9
 
10
void
11
closure_test_fn(ffi_cif* cif, void* resp, void** args, void* userdata)
12
{
13
  throw 9;
14
}
15
 
16
typedef void (*closure_test_type)();
17
 
18
void closure_test_fn1(ffi_cif* cif,void* resp,void** args,
19
                             void* userdata)
20
 {
21
    *(ffi_arg*)resp =
22
      (int)*(float *)args[0] +(int)(*(float *)args[1]) +
23
      (int)(*(float *)args[2]) + (int)*(float *)args[3] +
24
      (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
25
      (int)*(float *)args[6] + (int)(*(int *)args[7]) +
26
      (int)(*(double*)args[8]) + (int)*(int *)args[9] +
27
      (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
28
      (int)*(int *)args[12] + (int)(*(int *)args[13]) +
29
      (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
30
 
31
    printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
32
           (int)*(float *)args[0], (int)(*(float *)args[1]),
33
           (int)(*(float *)args[2]), (int)*(float *)args[3],
34
           (int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
35
           (int)*(float *)args[6], (int)(*(int *)args[7]),
36
           (int)(*(double *)args[8]), (int)*(int *)args[9],
37
           (int)(*(int *)args[10]), (int)(*(float *)args[11]),
38
           (int)*(int *)args[12], (int)(*(int *)args[13]),
39
           (int)(*(int *)args[14]), *(int *)args[15],
40
           (int)(long)userdata, (int)*(ffi_arg*)resp);
41
 
42
    throw (int)*(ffi_arg*)resp;
43
}
44
 
45
typedef int (*closure_test_type1)(float, float, float, float, signed short,
46
                                  float, float, int, double, int, int, float,
47
                                  int, int, int, int);
48
 
49
int main (void)
50
{
51
  ffi_cif cif;
52
#ifndef USING_MMAP
53
  static ffi_closure cl;
54
#endif
55
  ffi_closure *pcl;
56
  ffi_type * cl_arg_types[17];
57
  int res;
58
#ifdef USING_MMAP
59
  pcl = (ffi_closure *) allocate_mmap (sizeof(ffi_closure));
60
#else
61
  pcl = &cl;
62
#endif
63
 
64
  {
65
    cl_arg_types[1] = NULL;
66
 
67
    CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0,
68
                       &ffi_type_void, cl_arg_types) == FFI_OK);
69
    CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn, NULL) == FFI_OK);
70
 
71
    try
72
      {
73
        (*((closure_test_type)(pcl)))();
74
      } catch (int exception_code)
75
      {
76
        CHECK(exception_code == 9);
77
      }
78
 
79
    printf("part one OK\n");
80
    /* { dg-output "part one OK" } */
81
    }
82
 
83
    {
84
 
85
      cl_arg_types[0] = &ffi_type_float;
86
      cl_arg_types[1] = &ffi_type_float;
87
      cl_arg_types[2] = &ffi_type_float;
88
      cl_arg_types[3] = &ffi_type_float;
89
      cl_arg_types[4] = &ffi_type_sshort;
90
      cl_arg_types[5] = &ffi_type_float;
91
      cl_arg_types[6] = &ffi_type_float;
92
      cl_arg_types[7] = &ffi_type_uint;
93
      cl_arg_types[8] = &ffi_type_double;
94
      cl_arg_types[9] = &ffi_type_uint;
95
      cl_arg_types[10] = &ffi_type_uint;
96
      cl_arg_types[11] = &ffi_type_float;
97
      cl_arg_types[12] = &ffi_type_uint;
98
      cl_arg_types[13] = &ffi_type_uint;
99
      cl_arg_types[14] = &ffi_type_uint;
100
      cl_arg_types[15] = &ffi_type_uint;
101
      cl_arg_types[16] = NULL;
102
 
103
      /* Initialize the cif */
104
      CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
105
                         &ffi_type_sint, cl_arg_types) == FFI_OK);
106
 
107
      CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn1,
108
                             (void *) 3 /* userdata */)  == FFI_OK);
109
      try
110
        {
111
          (*((closure_test_type1)pcl))
112
            (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
113
             19, 21, 1);
114
          /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
115
        } catch (int exception_code)
116
        {
117
          CHECK(exception_code == 255);
118
        }
119
      printf("part two OK\n");
120
      /* { dg-output "\npart two OK" } */
121
    }
122
    exit(0);
123
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.