• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/pyobjc-45/pyobjc/pyobjc-core-2.5.1/libffi-src/tests/testsuite/libffi.call/
1/* Area:	ffi_call
2   Purpose:	Check strlen function call.
3   Limitations:	none.
4   PR:		none.
5   Originator:	From the original ffitest.c  */
6
7/* { dg-do run } */
8#include "ffitest.h"
9
10static int array_reverse(float *s, int len)
11{
12	int i;
13
14	for (i = 0; i < len/2;i++) {
15		float tmp = s[i];
16		s[i] = s[len-1-i];
17		s[len-1-i] = tmp;
18	}
19	return 1;
20}
21
22int main (void)
23{
24  ffi_cif cif;
25  ffi_type *args[MAX_ARGS];
26  void *values[MAX_ARGS];
27
28  int rint;
29  float value[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
30
31  struct X {
32	  int rint;
33	  float* input;
34	  int count;
35  } valbuf;
36
37  valbuf.input = value;
38  valbuf.count = 5;
39
40  args[0] = &ffi_type_pointer;
41  args[1] = &ffi_type_sint;
42  values[0] = (void*) &valbuf.input;
43  values[1] = (void*) &valbuf.count;
44
45  /* Initialize the cif */
46  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
47		     &ffi_type_sint, args) == FFI_OK);
48
49  printf("%f\n", valbuf.input[0]);
50
51  ffi_call(&cif, FFI_FN(array_reverse), &valbuf.rint, values);
52
53  printf("%f\n", valbuf.input[0]);
54  CHECK(valbuf.rint == 1);
55  CHECK(valbuf.count == 5);
56  CHECK(valbuf.input[0] == 5.0);
57  CHECK(valbuf.input[1] == 4.0);
58  CHECK(valbuf.input[2] == 3.0);
59  CHECK(valbuf.input[3] == 2.0);
60  CHECK(valbuf.input[4] == 1.0);
61
62  return 0;
63}
64
65