Commit Graph

6682 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 fd16ce12c7 tests/kernel/h_segv: Disable SIGFPE test on RISC-V.
No floating-point exception traps on RISC-V.

Also don't pass the result of divide-by-zero converted to integer to
usleep.  Although the floating-point result of divide-by-zero is
well-defined by IEEE 754 (+/-infinity), the outcome of C conversion
to integer is not.  And while on some architectures this might return
zero, on RISC-V it looks like it'll return all bits set.  And as of
PR 58184, usleep now honours sleeps longer than 1sec, which means
this will be waiting at least two billion microseconds, or about half
an hour...

So instead, just write the result to a volatile variable.
2024-05-14 15:54:16 +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
rillig 681c37d9da lint: in strict bool mode, allow do-while-0
Even though 0 is not a boolean constant, allow this common idiom, to
help in those cases where the C preprocessor used by lint does not mark
tokens as coming from system headers (Clang).
2024-05-12 12:28:34 +00:00
rillig 37d5546d18 tests/lint: clean up tests for strict bool mode 2024-05-12 11:46:14 +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
rillig 4bd7e6e13f lint: parse but otherwise ignore C23 attributes
The C23 attributes are only parsed before an expression in an expression
statement, as a proof of concept.  Other places will follow later.
2024-05-11 16:12:28 +00:00
rillig 9cfc443f88 lint: warn when comparing an integer to a floating point constant 2024-05-11 15:53:38 +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 2173c07c84 tests/usr.bin/mtree/t_sets: Add base32, base64, debug32, debug64. 2024-05-10 03:29:47 +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
rillig 64ab641533 lint: in C23 mode, allow storage classes in compound literals 2024-05-09 20:56:41 +00:00
rillig 2d37fed27b lint: add details to message about too many initializers 2024-05-09 20:53:13 +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
rillig 151775b8cf lint: in C23 mode, support the nullptr constant 2024-05-09 11:08:07 +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
rillig 1cdc580354 lint: in C23 mode, support the keywords 'bool', 'false' and 'true' 2024-05-07 21:13:26 +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
rillig fe6f732478 tests/lint: show that in C23 mode, bool is not yet defined
The tests in C11 and C23 mode look the same right now but will change
soon.

The warnings in the C11 test disappeared because after the first error,
warnings about unused variables are suppressed by check_variable_usage,
as they are often wrong.
2024-05-07 19:32:35 +00:00