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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libffi/] [testsuite/] [libffi.call/] [cls_multi_schar.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Area:        ffi_call, closure_call
2
   Purpose:     Check passing of multiple signed char values.
3
   Limitations: none.
4
   PR:          PR13221.
5
   Originator:  <hos@tamanegi.org> 20031129  */
6
 
7
/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
8
#include "ffitest.h"
9
 
10
signed char test_func_fn(signed char a1, signed char a2)
11
{
12
  signed char result;
13
 
14
  result = a1 + a2;
15
 
16
  printf("%d %d: %d\n", a1, a2, result);
17
 
18
  return result;
19
 
20
}
21
 
22
static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
23
{
24
  signed char a1, a2;
25
 
26
  a1 = *(signed char *)avals[0];
27
  a2 = *(signed char *)avals[1];
28
 
29
  *(ffi_arg *)rval = test_func_fn(a1, a2);
30
 
31
}
32
 
33
typedef signed char (*test_type)(signed char, signed char);
34
 
35
int main (void)
36
{
37
  ffi_cif cif;
38
#ifndef USING_MMAP
39
  static ffi_closure cl;
40
#endif
41
  ffi_closure *pcl;
42
  void * args_dbl[3];
43
  ffi_type * cl_arg_types[3];
44
  ffi_arg res_call;
45
  signed char a, b, res_closure;
46
 
47
#ifdef USING_MMAP
48
  pcl = allocate_mmap (sizeof(ffi_closure));
49
#else
50
  pcl = &cl;
51
#endif
52
 
53
  a = 2;
54
  b = 125;
55
 
56
  args_dbl[0] = &a;
57
  args_dbl[1] = &b;
58
  args_dbl[2] = NULL;
59
 
60
  cl_arg_types[0] = &ffi_type_schar;
61
  cl_arg_types[1] = &ffi_type_schar;
62
  cl_arg_types[2] = NULL;
63
 
64
  /* Initialize the cif */
65
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
66
                     &ffi_type_schar, cl_arg_types) == FFI_OK);
67
 
68
  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
69
  /* { dg-output "2 125: 127" } */
70
  printf("res: %d\n", res_call);
71
  /* { dg-output "\nres: 127" } */
72
 
73
  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
74
 
75
  res_closure = (*((test_type)pcl))(2, 125);
76
  /* { dg-output "\n2 125: 127" } */
77
  printf("res: %d\n", res_closure);
78
  /* { dg-output "\nres: 127" } */
79
 
80
  exit(0);
81
}

powered by: WebSVN 2.1.0

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