Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

return_ll1.c
Go to the documentation of this file.
1 /* Area: ffi_call
2 Purpose: Check if long long are passed in the corresponding regs on ppc.
3 Limitations: none.
4 PR: 20104.
5 Originator: <andreast@gcc.gnu.org> 20050222 */
6
7 /* { dg-do run } */
8 /* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
9 #include "ffitest.h"
10 static long long return_ll(int ll0, long long ll1, int ll2)
11 {
12 return ll0 + ll1 + ll2;
13 }
14
15 int main (void)
16 {
17 ffi_cif cif;
18 ffi_type *args[MAX_ARGS];
19 void *values[MAX_ARGS];
20 long long rlonglong;
21 long long ll1;
22 unsigned ll0, ll2;
23
24 args[0] = &ffi_type_sint;
25 args[1] = &ffi_type_sint64;
26 args[2] = &ffi_type_sint;
27 values[0] = &ll0;
28 values[1] = &ll1;
29 values[2] = &ll2;
30
31 /* Initialize the cif */
32 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
33 &ffi_type_sint64, args) == FFI_OK);
34
35 ll0 = 11111111;
36 ll1 = 11111111111000LL;
37 ll2 = 11111111;
38
39 ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
40 printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2);
41 /* { dg-output "res: 11111133333222, 11111133333222" } */
42 exit(0);
43 }
printf
int int int printf(const char *__restrict,...) __attribute__((__format__(__printf__
exit
void exit(int __status) __attribute__((__noreturn__))
PRIdLL
#define PRIdLL
Definition: ffitest.h:70
ffitest.h
main
int main(void)
Definition: return_ll1.c:15
CHECK
#define CHECK(sub)
Definition: compile.c:448
FFI_DEFAULT_ABI
@ FFI_DEFAULT_ABI
Definition: ffitarget.h:38
ffi_prep_cif
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)
Definition: prep_cif.c:226
MAX_ARGS
#define MAX_ARGS
Definition: function.c:15
ffi_call
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
Definition: ffi.c:813