• 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/* { dg-do run } */
2#include "ffitest.h"
3
4static long chars(long a,
5		  char b1,
6		  char b2,
7		  char b3,
8		  char b4,
9		  char b5,
10		  char b6,
11		  char b7,
12		  char b8,
13		  char b9,
14		  char b10,
15		  char b11,
16		  char b12,
17		  char b13,
18		  char b14,
19		  char b15,
20		  char b16)
21
22{
23  printf("%ld %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
24	a, (int)b1, (int)b2, (int)b3, (int)b4, (int)b5, (int)b6,
25	(int)b7, (int)b8, (int)b9, (int)b10, (int)b11, (int)b12,
26	(int)b13, (int)b14, (int)b15, (int)b16);
27  return a+b1+b2+b3+b4+b5+b6+b7+b8+b9+b10+b11+b12+b13+b14+b15+b16;
28}
29
30int main (void)
31{
32  ffi_cif cif;
33  ffi_type *args[17];
34  void *values[17];
35  long a1,r;
36  char bytes[16];
37  int i;
38
39  args[0] = &ffi_type_slong;
40  values[i] = &a1;
41  a1 = 0;
42
43  for (i = 1; i < 17; i++)
44    {
45      args[i] = &ffi_type_sint8;
46      values[i] = &bytes[i-1];
47      bytes[i-1] = i;
48    }
49
50    /* Initialize the cif */
51    CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 17,
52		       &ffi_type_slong, args) == FFI_OK);
53
54    ffi_call(&cif, FFI_FN(chars), &r, values);
55    /* dg-output: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
56
57    printf("%ld\n", r);
58    /* dg-output: 136 */
59
60    r =  chars(a1, bytes[0], bytes[1], bytes[2], bytes[3],
61		    bytes[4], bytes[5], bytes[6], bytes[7],
62		    bytes[8], bytes[9], bytes[10], bytes[11],
63		    bytes[12], bytes[13], bytes[14], bytes[15]);
64    /* dg-output: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
65    printf("%ld\n", r);
66    /* dg-output: 136 */
67
68    return 0;
69}
70