Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
cls_uint_va.c
Go to the documentation of this file.
1/* Area: closure_call
2 Purpose: Test anonymous unsigned int argument.
3 Limitations: none.
4 PR: none.
5 Originator: ARM Ltd. */
6
7/* { dg-do run } */
8
9#include "ffitest.h"
10
11typedef unsigned int T;
12
13static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14 void* userdata __UNUSED__)
15 {
16 *(ffi_arg *)resp = *(T *)args[0];
17
18 printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]);
19 }
20
21typedef T (*cls_ret_T)(T, ...);
22
23int main (void)
24{
25 ffi_cif cif;
26 void *code;
27 ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 ffi_type * cl_arg_types[3];
29 T res;
30
31 cl_arg_types[0] = &ffi_type_uint;
32 cl_arg_types[1] = &ffi_type_uint;
33 cl_arg_types[2] = NULL;
34
35 /* Initialize the cif */
37 &ffi_type_uint, cl_arg_types) == FFI_OK);
38
39 CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
40 res = ((((cls_ret_T)code)(67, 4)));
41 /* { dg-output "67: 67 4" } */
42 printf("res: %d\n", res);
43 /* { dg-output "\nres: 67" } */
44 exit(0);
45}
ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, void **, void *), void *user_data, void *codeloc)
Definition: ffi.c:928
unsigned long ffi_arg
Definition: ffitarget.h:30
@ FFI_DEFAULT_ABI
Definition: ffitarget.h:38
unsigned char T
Definition: cls_uchar_va.c:10
unsigned int T
Definition: cls_uint_va.c:11
int main(void)
Definition: cls_uint_va.c:23
T(* cls_ret_T)(T,...)
Definition: cls_uint_va.c:21
#define CHECK(sub)
Definition: compile.c:448
#define __UNUSED__
Definition: ffitest.h:28
ffi_status ffi_prep_cif_var(ffi_cif *cif, ffi_abi abi, unsigned int nfixedargs, unsigned int ntotalargs, ffi_type *rtype, ffi_type **atypes)
Definition: prep_cif.c:232
#define NULL
int int int printf(const char *__restrict__,...) __attribute__((__format__(__printf__
void exit(int __status) __attribute__((__noreturn__))