From 63d7c9d61ee8071e39cbc876d47f32ffac5827cd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 19 Jun 2024 02:58:34 +0200 Subject: [PATCH] copysignl tests: Avoid failure on Solaris 11.4. * tests/test-copysignl.c: Include . (LDBL_BYTES): New macro. (main): Use it instead of sizeof (long double). * modules/copysignl-tests (Depends-on): Add float. --- ChangeLog | 8 ++++++++ modules/copysignl-tests | 1 + tests/test-copysignl.c | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 727f8585b8..85fac1e978 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-18 Bruno Haible + + copysignl tests: Avoid failure on Solaris 11.4. + * tests/test-copysignl.c: Include . + (LDBL_BYTES): New macro. + (main): Use it instead of sizeof (long double). + * modules/copysignl-tests (Depends-on): Add float. + 2024-06-18 Bruno Haible mbsnlen: Fix bug (regression 2023-09-26). diff --git a/modules/copysignl-tests b/modules/copysignl-tests index 1cb5f829aa..e3a5b79c96 100644 --- a/modules/copysignl-tests +++ b/modules/copysignl-tests @@ -5,6 +5,7 @@ tests/minus-zero.h tests/macros.h Depends-on: +float configure.ac: diff --git a/tests/test-copysignl.c b/tests/test-copysignl.c index b2b78aa849..fc4c906573 100644 --- a/tests/test-copysignl.c +++ b/tests/test-copysignl.c @@ -26,6 +26,7 @@ SIGNATURE_CHECK (copysignl, long double, (long double, long double)); #include "macros.h" #include "minus-zero.h" +#include #include volatile long double x; @@ -33,6 +34,14 @@ volatile long double y; long double z; long double zero = 0.0L; +/* Number of bytes occupied by a 'long double' in memory. */ +#if (defined __ia64 || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && LDBL_MANT_DIG == 64 +/* 'long double' is little-endian 80-bits "extended precision". */ +# define LDBL_BYTES 10 +#else +# define LDBL_BYTES sizeof (long double) +#endif + int main () { @@ -87,25 +96,25 @@ main () y = 1.0L; z = copysignl (x, y); ASSERT (z == 0.0L); - ASSERT (memcmp (&z, &zero, sizeof z) == 0); + ASSERT (memcmp (&z, &zero, LDBL_BYTES) == 0); x = 0.0L; y = -1.0L; z = copysignl (x, y); ASSERT (z == 0.0L); - ASSERT (memcmp (&z, &zero, sizeof z) != 0); + ASSERT (memcmp (&z, &zero, LDBL_BYTES) != 0); x = minus_zerol; y = 1.0L; z = copysignl (x, y); ASSERT (z == 0.0L); - ASSERT (memcmp (&z, &zero, sizeof z) == 0); + ASSERT (memcmp (&z, &zero, LDBL_BYTES) == 0); x = minus_zerol; y = -1.0L; z = copysignl (x, y); ASSERT (z == 0.0L); - ASSERT (memcmp (&z, &zero, sizeof z) != 0); + ASSERT (memcmp (&z, &zero, LDBL_BYTES) != 0); return 0; } -- 2.39.5