Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
many.c
Go to the documentation of this file.
1/* Area: ffi_call
2 Purpose: Check return value float, with many arguments
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
6
7/* { dg-do run } */
8#include "ffitest.h"
9
10#include <stdlib.h>
11#include <float.h>
12#include <math.h>
13
14static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13)
15{
16#if 0
17 printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
18 (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
19 (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
20 (double) f11, (double) f12, (double) f13);
21#endif
22
23 return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13;
24}
25
26int main (void)
27{
28 ffi_cif cif;
29 ffi_type *args[13];
30 void *values[13];
31 float fa[13];
32 float f, ff;
33 int i;
34
35 for (i = 0; i < 13; i++)
36 {
37 args[i] = &ffi_type_float;
38 values[i] = &fa[i];
39 fa[i] = (float) i;
40 }
41
42 /* Initialize the cif */
43 CHECK(ffi_prep_cif(&cif, ABI_NUM, 13,
44 &ffi_type_float, args) == FFI_OK);
45
46 ffi_call(&cif, FFI_FN(many), &f, values);
47
48 ff = many(fa[0], fa[1],
49 fa[2], fa[3],
50 fa[4], fa[5],
51 fa[6], fa[7],
52 fa[8], fa[9],
53 fa[10],fa[11],fa[12]);
54
55 if (fabs(f - ff) < FLT_EPSILON)
56 exit(0);
57 else
58 abort();
59}
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
Definition: ffi.c:813
#define CHECK(sub)
Definition: compile.c:448
#define ABI_NUM
Definition: ffitest.h:35
#define ABI_ATTR
Definition: ffitest.h:36
int main(void)
Definition: many.c:26
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
double fabs(double)
int int int printf(const char *__restrict__,...) __attribute__((__format__(__printf__
uint32_t i
void exit(int __status) __attribute__((__noreturn__))
void abort(void) __attribute__((__noreturn__))
#define f