Ruby  2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
many2.c
Go to the documentation of this file.
1 /* Area: ffi_call
2  Purpose: Check uint8_t arguments.
3  Limitations: none.
4  PR: PR45677.
5  Originator: Dan Witte <dwitte@gmail.com> 20100916 */
6 
7 /* { dg-do run } */
8 
9 #include "ffitest.h"
10 
11 #define NARGS 7
12 
13 typedef unsigned char u8;
14 
15 #ifdef __GNUC__
16 __attribute__((noinline))
17 #endif
18 uint8_t
20  uint8_t e, uint8_t f, uint8_t g)
21 {
22  return a + b + c + d + e + f + g;
23 }
24 
27  uint8_t e, uint8_t f, uint8_t g)
28 {
29  return foo (a, b, c, d, e, f, g);
30 }
31 
32 int
33 main (void)
34 {
35  ffi_type *ffitypes[NARGS];
36  int i;
37  ffi_cif cif;
38  ffi_arg result = 0;
39  uint8_t args[NARGS];
40  void *argptrs[NARGS];
41 
42  for (i = 0; i < NARGS; ++i)
43  ffitypes[i] = &ffi_type_uint8;
44 
46  &ffi_type_uint8, ffitypes) == FFI_OK);
47 
48  for (i = 0; i < NARGS; ++i)
49  {
50  args[i] = i;
51  argptrs[i] = &args[i];
52  }
53  ffi_call (&cif, FFI_FN (bar), &result, argptrs);
54 
55  CHECK (result == 21);
56  return 0;
57 }
__attribute__
unsigned int UINT8 __attribute__((__mode__(__QI__)))
Definition: ffi_common.h:110
i
uint32_t i
Definition: rb_mjit_min_header-2.7.1.h:5464
ffi_arg
unsigned long ffi_arg
Definition: ffitarget.h:30
NARGS
#define NARGS
Definition: many2.c:11
ABI_NUM
#define ABI_NUM
Definition: ffitest.h:35
ffitest.h
main
int main(void)
Definition: many2.c:33
CHECK
#define CHECK(sub)
Definition: compile.c:448
uint8_t
unsigned char uint8_t
Definition: sha2.h:100
f
#define f
ABI_ATTR
#define ABI_ATTR
Definition: ffitest.h:36
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
foo
uint8_t foo(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g)
Definition: many2.c:19
ffi_call
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
Definition: ffi.c:813
u8
unsigned char u8
Definition: many2.c:13
bar
uint8_t ABI_ATTR bar(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g)
Definition: many2.c:26