• 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:	Promotion test.
3   Limitations:	none.
4   PR:		none.
5   Originator:	From the original ffitest.c  */
6
7/* { dg-do run } */
8#include "ffitest.h"
9static inline unsigned int promotion(short s1, short s2)
10{
11  unsigned int r = s1 << 16 | s2;
12
13  return r;
14}
15
16int main (void)
17{
18  ffi_cif cif;
19  ffi_type *args[MAX_ARGS];
20  void *values[MAX_ARGS];
21  ffi_arg rint;
22  short us;
23  short us2;
24  unsigned long ul = 0;
25
26  args[0] = &ffi_type_ushort;
27  args[1] = &ffi_type_ushort;
28  values[0] = &us;
29  values[1] = &us2;
30
31  /* Initialize the cif */
32  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
33		     &ffi_type_uint, args) == FFI_OK);
34
35  for (us = 55; us < 30000; us+=1034) {
36    for (us2 = 100; us2 < 30000; us2+=1945) {
37      ffi_call(&cif, FFI_FN(promotion), &rint, values);
38      CHECK((unsigned int)rint == (us << 16 | us2));
39    }
40  }
41  printf("%lu promotion2 tests run\n", ul);
42  exit(0);
43}
44