Add test case
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
diff --git a/testsuite/libffi.call/s55.c b/testsuite/libffi.call/s55.c
new file mode 100644
index 0000000..94dfd5f
--- /dev/null
+++ b/testsuite/libffi.call/s55.c
@@ -0,0 +1,60 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ float f;
+} s55;
+
+static s55 ABI_ATTR f55(s55 ts, float f)
+{
+ s55 r;
+ r.f = ts.f + f;
+ printf ("f55>> %g + %g = %g\n", ts.f, f, r.f);
+ return r;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ s55 F, Fr;
+ float f;
+ void *values[] = { &F, &f };
+ ffi_type s55_type;
+ ffi_type *args[] = { &s55_type, &ffi_type_float };
+ ffi_type *s55_type_elements[] = { &ffi_type_float, NULL };
+
+ /* This is a hack to get a properly aligned result buffer */
+ s55 *s55_result =
+ (s55 *) malloc (sizeof(s55));
+
+ s55_type.size = 0;
+ s55_type.alignment = 0;
+ s55_type.type = FFI_TYPE_STRUCT;
+ s55_type.elements = s55_type_elements;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &s55_type, args) == FFI_OK);
+
+ F.f = 1;
+ Fr = f55(F, 2.14);
+ printf ("%g\n", Fr.f);
+
+ F.f = 1;
+ f = 2.14;
+ ffi_call(&cif, FFI_FN(f55), s55_result, values);
+ printf ("%g\n", s55_result->f);
+
+ fflush(0);
+
+ CHECK(fabs(Fr.f - s55_result->f) < FLT_EPSILON);
+
+ free (s55_result);
+ exit(0);
+}