2 Purpose: Promotion test.
5 Originator: From the original ffitest.c */
9 static int promotion(signed char sc
, signed short ss
,
10 unsigned char uc
, unsigned short us
)
12 int r
= (int) sc
+ (int) ss
+ (int) uc
+ (int) us
;
20 ffi_type
*args
[MAX_ARGS
];
21 void *values
[MAX_ARGS
];
29 args
[0] = &ffi_type_schar
;
30 args
[1] = &ffi_type_sshort
;
31 args
[2] = &ffi_type_uchar
;
32 args
[3] = &ffi_type_ushort
;
38 /* Initialize the cif */
39 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 4,
40 &ffi_type_sint
, args
) == FFI_OK
);
45 for (sc
= (signed char) -127;
46 sc
<= (signed char) 120; sc
+= 1)
47 for (ss
= -30000; ss
<= 30000; ss
+= 10000)
48 for (uc
= (unsigned char) 0;
49 uc
<= (unsigned char) 200; uc
+= 20)
50 for (us
= 0; us
<= 60000; us
+= 10000)
53 ffi_call(&cif
, FFI_FN(promotion
), &rint
, values
);
54 CHECK((int)rint
== (signed char) sc
+ (signed short) ss
+
55 (unsigned char) uc
+ (unsigned short) us
);
57 printf("%lu promotion tests run\n", ul
);