1 /* Area: ffi_call, closure_call
2 Purpose: Check pointer arguments.
5 Originator: Blake Chaffin 6/6/2007 */
7 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
10 void* cls_pointer_fn(void* a1
, void* a2
)
12 void* result
= (void*)((intptr_t)a1
+ (intptr_t)a2
);
14 printf("0x%08x 0x%08x: 0x%08x\n",
15 (unsigned int)(uintptr_t) a1
,
16 (unsigned int)(uintptr_t) a2
,
17 (unsigned int)(uintptr_t) result
);
23 cls_pointer_gn(ffi_cif
* cif __UNUSED__
, void* resp
,
24 void** args
, void* userdata __UNUSED__
)
26 void* a1
= *(void**)(args
[0]);
27 void* a2
= *(void**)(args
[1]);
29 *(void**)resp
= cls_pointer_fn(a1
, a2
);
36 ffi_closure
* pcl
= ffi_closure_alloc(sizeof(ffi_closure
), &code
);
38 // ffi_type cls_pointer_type;
39 ffi_type
* arg_types
[3];
41 /* cls_pointer_type.size = sizeof(void*);
42 cls_pointer_type.alignment = 0;
43 cls_pointer_type.type = FFI_TYPE_POINTER;
44 cls_pointer_type.elements = NULL;*/
46 void* arg1
= (void*)0x12345678;
47 void* arg2
= (void*)0x89abcdef;
50 arg_types
[0] = &ffi_type_pointer
;
51 arg_types
[1] = &ffi_type_pointer
;
54 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 2, &ffi_type_pointer
,
55 arg_types
) == FFI_OK
);
61 ffi_call(&cif
, FFI_FN(cls_pointer_fn
), &res
, args
);
62 /* { dg-output "0x12345678 0x89abcdef: 0x9be02467" } */
63 printf("res: 0x%08x\n", (unsigned int) res
);
64 /* { dg-output "\nres: 0x9be02467" } */
66 CHECK(ffi_prep_closure_loc(pcl
, &cif
, cls_pointer_gn
, NULL
, code
) == FFI_OK
);
68 res
= (ffi_arg
)(uintptr_t)((void*(*)(void*, void*))(code
))(arg1
, arg2
);
69 /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
70 printf("res: 0x%08x\n", (unsigned int) res
);
71 /* { dg-output "\nres: 0x9be02467" } */