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/] [struct3.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Area:        ffi_call
2
   Purpose:     Check structures.
3
   Limitations: none.
4
   PR:          none.
5
   Originator:  From the original ffitest.c  */
6
 
7
/* { dg-do run } */
8
#include "ffitest.h"
9
 
10
typedef struct
11
{
12
  int si;
13
} test_structure_3;
14
 
15
static test_structure_3 struct3(test_structure_3 ts)
16
{
17
  ts.si = -(ts.si*2);
18
 
19
  return ts;
20
}
21
 
22
int main (void)
23
{
24
  ffi_cif cif;
25
  ffi_type *args[MAX_ARGS];
26
  void *values[MAX_ARGS];
27
  int compare_value;
28
  ffi_type ts3_type;
29
  ffi_type *ts3_type_elements[2];
30
  ts3_type.size = 0;
31
  ts3_type.alignment = 0;
32
  ts3_type.type = FFI_TYPE_STRUCT;
33
  ts3_type.elements = ts3_type_elements;
34
  ts3_type_elements[0] = &ffi_type_sint;
35
  ts3_type_elements[1] = NULL;
36
 
37
  test_structure_3 ts3_arg;
38
  test_structure_3 *ts3_result =
39
    (test_structure_3 *) malloc (sizeof(test_structure_3));
40
 
41
  args[0] = &ts3_type;
42
  values[0] = &ts3_arg;
43
 
44
  /* Initialize the cif */
45
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
46
                     &ts3_type, args) == FFI_OK);
47
 
48
  ts3_arg.si = -123;
49
  compare_value = ts3_arg.si;
50
 
51
  ffi_call(&cif, FFI_FN(struct3), ts3_result, values);
52
 
53
  printf ("%d %d\n", ts3_result->si, -(compare_value*2));
54
 
55
  CHECK(ts3_result->si == -(compare_value*2));
56
 
57
  free (ts3_result);
58
  exit(0);
59
}

powered by: WebSVN 2.1.0

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