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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
https://github.com/libffi/libffi/commit/efb98a72d8b9bdb71b4f972efced073bee3b30fc
https://github.com/libffi/libffi/commit/92d384df196a099fde384f9178864dbfe8c6b0fc
From efb98a72d8b9bdb71b4f972efced073bee3b30fc Mon Sep 17 00:00:00 2001
From: Anthony Green <green@moxielogic.com>
Date: Sun, 15 Sep 2024 07:31:33 -0400
Subject: [PATCH] Robustify floating point comparison in test
---
testsuite/libffi.call/struct_int_float.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/testsuite/libffi.call/struct_int_float.c b/testsuite/libffi.call/struct_int_float.c
index dab1d1fed..82685814c 100644
--- a/testsuite/libffi.call/struct_int_float.c
+++ b/testsuite/libffi.call/struct_int_float.c
@@ -54,35 +54,35 @@ int main (void)
values[4] = &ts_arg[4];
args[5] = &ts_type;
values[5] = &ts_arg[5];
-
+
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, ABI_NUM, 6, &ffi_type_float, args) == FFI_OK);
-
+
ts_arg[0].i = 1;
- ts_arg[0].f = 1.11f;
+ ts_arg[0].f = 11.11f;
ts_arg[1].i = 2;
- ts_arg[1].f = 2.22f;
+ ts_arg[1].f = 22.22f;
ts_arg[2].i = 3;
- ts_arg[2].f = 3.33f;
+ ts_arg[2].f = 33.33f;
ts_arg[3].i = 4;
- ts_arg[3].f = 4.44f;
+ ts_arg[3].f = 44.44f;
ts_arg[4].i = 5;
- ts_arg[4].f = 5.55f;
+ ts_arg[4].f = 55.55f;
ts_arg[5].i = 6;
- ts_arg[5].f = 6.66f;
-
+ ts_arg[5].f = 66.66f;
+
printf ("%g\n", ts_arg[0].f);
printf ("%g\n", ts_arg[1].f);
printf ("%g\n", ts_arg[2].f);
printf ("%g\n", ts_arg[3].f);
printf ("%g\n", ts_arg[4].f);
printf ("%g\n", ts_arg[5].f);
-
+
ffi_call(&cif, FFI_FN(struct_int_float), &rfloat, values);
printf ("%g\n", rfloat);
-
- CHECK(rfloat == 1.11f);
+
+ CHECK(fabs(rfloat - 11.11) < FLT_EPSILON);
exit(0);
}
From 92d384df196a099fde384f9178864dbfe8c6b0fc Mon Sep 17 00:00:00 2001
From: Anthony Green <green@moxielogic.com>
Date: Sun, 15 Sep 2024 12:32:29 -0400
Subject: [PATCH] Fix floating point compare
---
testsuite/libffi.call/struct_int_float.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/testsuite/libffi.call/struct_int_float.c b/testsuite/libffi.call/struct_int_float.c
index 82685814..66ef6c45 100644
--- a/testsuite/libffi.call/struct_int_float.c
+++ b/testsuite/libffi.call/struct_int_float.c
@@ -14,11 +14,11 @@ typedef struct
} test_structure_int_float;
static float ABI_ATTR struct_int_float(test_structure_int_float ts1,
- test_structure_int_float ts2,
- test_structure_int_float ts3,
- test_structure_int_float ts4,
- test_structure_int_float ts5,
- test_structure_int_float ts6)
+ test_structure_int_float ts2 __UNUSED__,
+ test_structure_int_float ts3 __UNUSED__,
+ test_structure_int_float ts4 __UNUSED__,
+ test_structure_int_float ts5 __UNUSED__,
+ test_structure_int_float ts6 __UNUSED__)
{
return ts1.f;
}
@@ -82,7 +82,7 @@ int main (void)
printf ("%g\n", rfloat);
- CHECK(fabs(rfloat - 11.11) < FLT_EPSILON);
+ CHECK(fabs(rfloat - 11.11) < 3 * FLT_EPSILON);
exit(0);
}
|