]> Savannah Git Hosting - gnulib.git/commitdiff
copysignl tests: Avoid failure on Solaris 11.4.
authorBruno Haible <bruno@clisp.org>
Wed, 19 Jun 2024 00:58:34 +0000 (02:58 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 19 Jun 2024 00:58:56 +0000 (02:58 +0200)
* tests/test-copysignl.c: Include <float.h>.
(LDBL_BYTES): New macro.
(main): Use it instead of sizeof (long double).
* modules/copysignl-tests (Depends-on): Add float.

ChangeLog
modules/copysignl-tests
tests/test-copysignl.c

index 330bf49b325abf33025ac272033a76ba6b034263..988f36b6fc90a1fefbfcb2223a1cc7d2782be428 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-18  Bruno Haible  <bruno@clisp.org>
+
+       copysignl tests: Avoid failure on Solaris 11.4.
+       * tests/test-copysignl.c: Include <float.h>.
+       (LDBL_BYTES): New macro.
+       (main): Use it instead of sizeof (long double).
+       * modules/copysignl-tests (Depends-on): Add float.
+
 2024-06-18  Bruno Haible  <bruno@clisp.org>
 
        mbsnlen: Add tests.
index 1cb5f829aaa9cac4125c3d79be7cba813e46a550..e3a5b79c968dbfc59b5f890581198f2c6273948d 100644 (file)
@@ -5,6 +5,7 @@ tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
+float
 
 configure.ac:
 
index 8f5f188872d556af444fc6bf1d04db77573b1b9f..f17d045b404b7f5df25b904c9bc28789c5365d5c 100644 (file)
@@ -26,6 +26,7 @@ SIGNATURE_CHECK (copysignl, long double, (long double, long double));
 #include "macros.h"
 #include "minus-zero.h"
 
+#include <float.h>
 #include <string.h>
 
 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 test_exit_status;
 }