Commit Graph

2260 Commits

Author SHA1 Message Date
thorpej 7c0fd13281 Mark as expected-fail on VAX (PR port-vax/58290). 2024-05-27 22:03:21 +00:00
riastradh ddb7e40487 t_siginfo: More volatile to prevent optimization. 2024-05-20 11:21:46 +00:00
riastradh c95d2b6372 libstdc++: Don't try to fflush stdin.
It doesn't work.  It's undefined behaviour.  On NetBSD, it will fail
with EBADF, if fd 0 isn't open for write, or if fd 0 is open for
write, it will write heap garbage to fd 0.

   If stream points to an output stream or an update stream in which
   the most recent operation was not input, the fflush function causes
   any unwritten data for that stream to be delivered to the host
   environment to be written to the file; otherwise, the behavior is
   undefined.

   (ISO C11 and ISO C17, Sec. 7.21.5.2 `The fflush function')

PR lib/58206
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879
2024-05-20 11:20:53 +00:00
christos 8ba66bcbe2 Adjust to the new dup3 behavior for equal fds 2024-05-20 00:27:53 +00:00
riastradh 906e271cb3 modfl(3): Fix conversion from FreeBSD.
LDBL_MANL_SIZE is spelled EXT_FRACLBITS -- and not EXT_FRACHBITS.

PR lib/58237: modfl returns wrong answers on ld128 architectures
2024-05-15 00:02:56 +00:00
riastradh 5e6d5edb94 t_siginfo: Use volatile to prevent optimization. 2024-05-14 16:10:54 +00:00
riastradh fc245f77a0 t_siginfo: No SIGFPE on RISC-V. 2024-05-14 16:10:14 +00:00
riastradh fc5f862a3e t_ptrace_wait: No FPU exception traps on RISC-V.
This macro is not named correctly -- RISC-V does implement
floating-point exceptions, but only via sticky status bits, not via
machine traps.
2024-05-14 16:06:20 +00:00
riastradh c4f7f3bcf7 t_ptrace_wait: Force result by write to volatile, not call to usleep.
This is causing each FPE-related test to time out because it's
actually passinga large number to usleep, which now respects large
numbers.
2024-05-14 16:04:17 +00:00
riastradh e14c40965f t_ilogb: Nix spurious line break in ATF_CHECK_MSG. 2024-05-14 15:31:42 +00:00
riastradh 71e5ba3aae t_fpsetmask, t_fenv: Skip fp exception trap tests on RISC-V.
No architectural support for fp exception traps.

While here, make the macros behave a little better as C statements.
2024-05-14 14:55:43 +00:00
rillig 7e2cd5d094 tests/t_hypot: actually add nan test 2024-05-13 20:28:15 +00:00
riastradh 7b97efbd1d tests/lib/libm/t_fenv: Work around PR 58253. 2024-05-12 21:53:26 +00:00
riastradh c37983148b t_hypot: Use an ld80 test case that actually fits in ld80.
Also add comments explaining how I generated these test cases.

(No autoconf back doors hidden in these magic numbers, I promise!  No
pythagoreans were harmed in the production of these tests either.)
2024-05-12 20:58:44 +00:00
riastradh fbb3f7e8bd tests/lib/libm/t_next: Disable a test if long double is double.
This test, to verify nexttoward(x, x*(1 - LDBL_EPSILON/2)) moves in
the direction of x*(1 - LDBL_EPSILON/2), only makes sense if long
double has more precision than double -- the point of the exercise is
to verify that nexttoward moves even if the direction parameter can't
be rounded to double.  But if long double is just double, this test
makes no sense.
2024-05-12 20:17:57 +00:00
riastradh 9fd6dfe53c tests/lib/libm/t_asin: Cite PR lib/58246. 2024-05-11 21:27:53 +00:00
riastradh d2baffa504 tests/lib/libm/t_hypot: Check inf/nan cases too. 2024-05-11 20:51:41 +00:00
riastradh 806be69ba7 hypotl(3): Fix includes and macros.
1. Need <math.h> for __HAVE_LONG_DOUBLE.
2. Need <machine/ieee.h> for struct ieee_ext_u &c.
3. EXT_FRACLBITS, not LDBL_MANL_SIZE.

PR lib/58245: hypotl is broken on ld128 ports
2024-05-11 20:09:47 +00:00
riastradh 0ca3b42cb3 tests/lib/libm/t_hypot: More trivial tests.
Check both signs of zero.
2024-05-11 20:09:13 +00:00
riastradh 3331daffc1 tests/lib/libm/t_hypot: Expand substantially.
PR lib/58245: hypotl is broken on ld128 ports
2024-05-11 19:08:29 +00:00
riastradh c5c7b2d6d4 tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.
Also link back to where the test case came from.
2024-05-11 14:39:53 +00:00
riastradh da294ec0fb tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.
printf %La does not write the `L' suffix.
2024-05-11 14:33:23 +00:00
riastradh bcaa0f35c3 nexttoward(3): Fix high-word test on small positive subnormals.
By this point in the logic, x can't be zero, so it's either positive
or negative.

The high word hx, however, can be zero, when x is a small positive
subnormal.  This means x is a small positive subnormal, so if x > y
we are computing nextDown, and if x < y we are computing nextUp.

hx is a (signed 32-bit) integer, not a double floating-point number,
so it's a little silly to compare hx > 0.0.  But that on its own
isn't enough to trigger the bug because all signed 32-bit integers
can be represented by double on all NetBSD architectures.

PR lib/58236
2024-05-11 02:07:53 +00:00
riastradh afce20e57c tests/lib/libm/t_next: nexttoward works if it's just nextafter.
It's broken on platforms where long double and double aren't the same
and nexttoward isn't an alias for nextafter.
2024-05-11 01:44:12 +00:00
riastradh 27df239d91 tests/lib/libc/stdio/t_printf: Fix another rounding error.
Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:

101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1

If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:

101.0100 1100 1101 * 2^1 = 0x5.4cdp+1
2024-05-09 22:38:29 +00:00
riastradh 9bda463035 tests/lib/libc/gen/t_fpclassify: Test fpclassify on non-IEEE754 too.
Just exclude the subnormal parts on non-IEEE754 architectures
according to __FLT/DBL/LDBL_HAS_DENORM__.
2024-05-09 14:44:39 +00:00
riastradh 22479c33fe tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.
Provide more useful diagnostics when tests fail.
2024-05-09 14:13:08 +00:00
riastradh ed2e8e1562 tests/lib/libm/t_infinity: Remove broken long double conditional.
LDBL_MAX is always defined, so this branch is dead.  (If LDBL_MAX is
not defined, that's a bug in the architecture's float.h, not a reason
to skip a test.)
2024-05-09 14:00:58 +00:00
riastradh 12802f72f7 Revert various broken changes to printf %La (hldtoa).
This reverts:

hdtoa.c 1.12 (PR/56247: Greg A. Woods: printf("%La", LDBL_MIN) dumps core)
hdtoa.c 1.11 (fix tyop)
hdtoa.c 1.10 (Via enh at google dot com in tech-userlevel. Fix handling of
    EXT_FRAC{H,L}BITS (although we don't need to since we don't have them).)

The underlying motivation for this change was that when ld128 is
decomposed into 4x32 words, this hldtoa logic is broken.

But we don't decompose ld128 into 4x32 words; we decompose it into
6x64 words.

And the change, which was supposed to be a noop in our case of 2x64
words (or similar for x87 80-bit floating-point), broke it to the
point of causing buffer overruns (PR 56247) which when worked around
led to just incorrect output output (PR 56937).

If we want to make the #ifdefs for 4x32 words work, that's fine, but
we absolutely must have automatic test cases to detect this kind of
regression because %La formatting is extremely important for
diagnosing details of floating-point data since it doesn't involve
rounding in binary formats.  For now I've added some trivial tests;
there is a more extensive test suite inside gdtoa that we need to
wire up before anyone tries any other shenanigans in this code.

PR lib/56937: printf(3) long double %a formatting is broken
2024-05-09 12:24:24 +00:00
riastradh decd27dde2 tests/lib/libm/t_ilogb: Expand and tidy.
1. Instead of calling out VAX by name, use #ifdef NAN and
   isinf(INFINITY).  (VAX defines INFINITY even though it's not an
   infinity, not sure if there's a better compile-time test.)

2. Verify ilogbl works on long double on all architectures, not just
   those with __HAVE_LONG_DOUBLE which means long double is _larger_
   than double.
2024-05-09 12:23:21 +00:00
riastradh 20b05e74e4 tests/lib/libm/t_fe_round.c: Tidy.
nextafter/nexttoward tests didn't make much sense, and are now
supplanted by t_next.

PR misc/58054
2024-05-09 12:18:28 +00:00
riastradh 47b9ac9413 tests/lib/libm/t_fe_round: xfail for modfl uses.
PR lib/58237: modfl returns wrong answers on ld128 architectures
2024-05-08 22:59:07 +00:00
riastradh 03e019893b tests/lib/libm/t_modf: Mark modfl xfail on ld128.
PR lib/58237: modfl returns wrong answers on ld128 architectures
2024-05-08 22:57:37 +00:00
riastradh 1252743ac7 tests/lib/libc/stdio/t_printf: Add another %La test.
This one was adapted from the screw case shown in

https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html

which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken
2024-05-08 20:23:15 +00:00
riastradh 65c3528ff8 tests/lib/libc/stdio/t_printf: Fix %a test the same way. 2024-05-08 20:19:37 +00:00
riastradh 1076b20b39 tests/lib/libc/stdio/t_printf: Fix %La test.
0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).
2024-05-08 20:04:33 +00:00
riastradh 5c6dfe9899 tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.
PR lib/56937: printf(3) long double %a formatting is broken
2024-05-08 18:19:57 +00:00
riastradh e37d2bb0d8 tests/lib/libm/t_next: Expand substantially.
This covers many more potential problem areas -- and includes a new
xfail test for PR lib/58236: nexttoward(3) is broken on subnormals.
2024-05-08 17:27:03 +00:00
riastradh d48db9a528 tests/lib/libc/gen/t_fpclassify: Enable long double tests.
The necessary long double symbols should all be available now.  If
there are any architectures where they're not, we can fix those
architectures.
2024-05-07 21:00:00 +00:00
riastradh 557aa1ae1a tests/lib/libm/t_bit: Expand and tidy.
1. Instead of calling out VAX by name, use #ifdef NAN.

2. Verify signbit works on long double on all architectures, not just
   those with __HAVE_LONG_DOUBLE which means long double is _larger_
   than double.

3. Minor formatting tidying.
2024-05-06 18:41:23 +00:00
riastradh 9da594439c tests/lib/libc/stdlib/t_strtod: Spruce up and nix needless #ifdefs. 2024-05-06 18:39:36 +00:00
riastradh 10d47f3307 tests/lib/libm/t_modf: Use isinf(INFINITY) to detect inf support.
Apparently VAX defines the INFINITY macro even though it's not
actually an infinity and isinf returns zero for it.
2024-05-06 18:35:59 +00:00
riastradh 30aeb9cc52 tests/lib/libc/gen/t_floatunditf: Nix __HAVE_LONG_DOUBLE conditional.
Conversion from uint64_t to long double should work on all ports,
including those where long double is the same as double, i.e., where
__HAVE_LONG_DOUBLE is undefined.

Instead, conditionalize the test cases on how many bits of precision
long double has in the significand, according to LDBL_MANT_DIG.  The
conditionals here should handle binary128, powerpc double-dekker
(~106-bit precision), x86 extended precision (80-bit), m68k extended
precision (80-bit), and VAX D (56-bit).
2024-05-06 17:53:43 +00:00
riastradh 49e81414d0 tests/lib/libm/t_sincos: Nix __HAVE_LONG_DOUBLE conditionals.
sincosl is supposed to be there even if long double is double, as is
the case when __HAVE_LONG_DOUBLE is undefined.
2024-05-06 15:53:46 +00:00
riastradh 742590c903 tests/lib/libm/t_scalbn: Nix __HAVE_LONG_DOUBLE conditionals.
If long double is the same as double, i.e., __HAVE_LONG_DOUBLE is
undefined, these tests should still pass, since they don't rely on
extra precision beyond double.
2024-05-06 15:49:31 +00:00
riastradh d36ac80d42 tests/lib/libm/t_precision: Nix __HAVE_LONG_DOUBLE conditionals.
long double and LDBL_EPSILON work even on architectures where long
double is the same as double, i.e., where the confusingly named
__HAVE_LONG_DOUBLE is not defined.
2024-05-06 15:46:31 +00:00
riastradh 26b22dc580 tests/lib/libm/t_cos: Fix comment about necessity of volatile. 2024-05-06 15:45:20 +00:00
riastradh 3d20dd055f tests/lib/libm/t_cos: Nix __HAVE_LONG_DOUBLE.
cosl should always be defined even on architectures where long double
is the same as double so the confusingly named __HAVE_LONG_DOUBLE is
not defined.
2024-05-06 15:44:08 +00:00
riastradh 840e85b4fd tests/lib/libm/t_cabsl: Nix __HAVE_LONG_DOUBLE conditionals.
__HAVE_LONG_DOUBLE just means long double is different from double.
This test should always pass on all ports, even if long double is the
same as double; it doesn't test any additional precision.
2024-05-06 15:40:55 +00:00
riastradh e21ed88e62 tests/lib/libc/setjmp/t_sigstack: Add missing comment for 1.10.
PR lib/57946
2024-05-06 12:11:03 +00:00