| 1 | n/a | /* Area:        closure_call | 
|---|
| 2 | n/a | Purpose:     Check return value long long. | 
|---|
| 3 | n/a | Limitations: none. | 
|---|
| 4 | n/a | PR:          none. | 
|---|
| 5 | n/a | Originator:  <andreast@gcc.gnu.org> 20030828  */ | 
|---|
| 6 | n/a |  | 
|---|
| 7 | n/a | /* { dg-do run } */ | 
|---|
| 8 | n/a | /* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ | 
|---|
| 9 | n/a | #include "ffitest.h" | 
|---|
| 10 | n/a |  | 
|---|
| 11 | n/a | static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp, | 
|---|
| 12 | n/a | void** args, void* userdata __UNUSED__) | 
|---|
| 13 | n/a | { | 
|---|
| 14 | n/a | *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0]; | 
|---|
| 15 | n/a |  | 
|---|
| 16 | n/a | printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0], | 
|---|
| 17 | n/a | *(unsigned long long *)(resp)); | 
|---|
| 18 | n/a | } | 
|---|
| 19 | n/a | typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long); | 
|---|
| 20 | n/a |  | 
|---|
| 21 | n/a | int main (void) | 
|---|
| 22 | n/a | { | 
|---|
| 23 | n/a | ffi_cif cif; | 
|---|
| 24 | n/a | void *code; | 
|---|
| 25 | n/a | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); | 
|---|
| 26 | n/a | ffi_type * cl_arg_types[2]; | 
|---|
| 27 | n/a | unsigned long long res; | 
|---|
| 28 | n/a |  | 
|---|
| 29 | n/a | cl_arg_types[0] = &ffi_type_uint64; | 
|---|
| 30 | n/a | cl_arg_types[1] = NULL; | 
|---|
| 31 | n/a |  | 
|---|
| 32 | n/a | /* Initialize the cif */ | 
|---|
| 33 | n/a | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, | 
|---|
| 34 | n/a | &ffi_type_uint64, cl_arg_types) == FFI_OK); | 
|---|
| 35 | n/a | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code)  == FFI_OK); | 
|---|
| 36 | n/a | res = (*((cls_ret_ulonglong)code))(214LL); | 
|---|
| 37 | n/a | /* { dg-output "214: 1152921504606846761" } */ | 
|---|
| 38 | n/a | printf("res: %" PRIdLL "\n", res); | 
|---|
| 39 | n/a | /* { dg-output "\nres: 1152921504606846761" } */ | 
|---|
| 40 | n/a |  | 
|---|
| 41 | n/a | res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); | 
|---|
| 42 | n/a | /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ | 
|---|
| 43 | n/a | printf("res: %" PRIdLL "\n", res); | 
|---|
| 44 | n/a | /* { dg-output "\nres: 8070450533247928831" } */ | 
|---|
| 45 | n/a |  | 
|---|
| 46 | n/a | exit(0); | 
|---|
| 47 | n/a | } | 
|---|