+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.
/* 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
#include "macros.h"
#include "minus-zero.h"
+#include <float.h>
#include <string.h>
volatile long double x;
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 ()
{
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;
}