]> 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>
Sun, 30 Jun 2024 22:31:28 +0000 (00:31 +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 e8d05a9c070d64f973ff31c5c38eb4a69959b388..be7a484265139c4ea595bd7dc02301c06c42526b 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-11  Bruno Haible  <bruno@clisp.org>
 
        test-framework-sh: Fix 'returns_' to not turn off tracing permanently.
index 1cb5f829aaa9cac4125c3d79be7cba813e46a550..e3a5b79c968dbfc59b5f890581198f2c6273948d 100644 (file)
@@ -5,6 +5,7 @@ tests/minus-zero.h
 tests/macros.h
 
 Depends-on:
+float
 
 configure.ac:
 
index 13b8e72e9d0e9f2e08c7204d8dcdfddbd1ac0139..fc4c906573400ef80cbb2813a479fde81e3e5a76 100644 (file)
@@ -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 <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 0;
 }