libffi/backport-Robustify-floating-point-comparison-in-test.patch

52 lines
1.4 KiB
Diff
Raw Normal View History

2025-01-14 09:15:11 +08:00
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
Conflict:NA
Reference:https://github.com/libffi/libffi/commit/efb98a72d8b9bdb71b4f972efced073bee3b30fc
---
testsuite/libffi.call/struct_int_float.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/testsuite/libffi.call/struct_int_float.c b/testsuite/libffi.call/struct_int_float.c
index 7014f13..079634e 100644
--- a/testsuite/libffi.call/struct_int_float.c
+++ b/testsuite/libffi.call/struct_int_float.c
@@ -61,17 +61,17 @@ int main (void)
CHECK(ffi_prep_cif(&cif, 2, 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);
@@ -84,7 +84,7 @@ int main (void)
printf ("%g\n", rfloat);
- CHECK(rfloat == 1.11f);
+ CHECK(fabs(rfloat - 11.11) < FLT_EPSILON);
exit(0);
}
--
2.27.0