From: Bruno Haible Date: Wed, 19 Jun 2024 00:58:34 +0000 (+0200) Subject: copysignl tests: Avoid failure on Solaris 11.4. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=97c2f51249c9c64213353734e77e0d3f68be0c10;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index e8d05a9c07..be7a484265 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-11 Bruno Haible test-framework-sh: Fix 'returns_' to not turn off tracing permanently. 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 13b8e72e9d..fc4c906573 100644 --- a/tests/test-copysignl.c +++ b/tests/test-copysignl.c @@ -1,5 +1,5 @@ /* Test of copysignl() function. - Copyright (C) 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2010-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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; }