Commit graph

85 commits

Author SHA1 Message Date
Steve Kargl 0dd5a5603e lib/msun: Cleanup after $FreeBSD$ removal
Remove no longer needed explicit inclusion of sys/cdefs.h.

PR:	276669
MFC after:	1 week
2024-01-28 17:00:23 +02:00
Warner Losh a2f733abcf lib: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Gordon Bergling 10889539ee msun: Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:57:38 +02:00
Dimitry Andric df3b437c1e Fix failures in libm's lround_test after clang 12 import
It turned out that the (type)DTYPE_MAX conversions at the top of
s_lround.c are now emitted as cvtsi2sd instructions, at least on SSE
capable CPUs. This caused the FE_INEXACT flag to always be set, at least
for the double and float variants. Under clang 11, the whole INRANGE()
comparisons were still optimized away, but this has "improved" in clang
12, due to stricter adherence to the -ffp-exception-behavior=maytrap
compiler flag.

To avoid run-time integer to float conversions, use static constants
instead, so they are computed at compile time, and the INRANGE()
statements are optimized away again, if applicable.

While here, use an integer instead of a floating type to store the test
results in lround_test.c, as this is more appropriate, and we can also
drop the volatile hack.

Reported by:	arichardson
MFC after:	3 days
2021-06-22 18:38:45 +02:00
Alex Richardson 1ad83445fc Allow lib/msun/logarithm_test to pass on ld128 platforms
For some reason the ld128 log1pl() implementation is less accurate than
logl(), but does at least guarantee precision >= the ld80 implementation.
Mark log1p_accuracy_tests as XFAIL for ld128 and increase the log1p tolerance
to the ld80 equivalent in accuracy_tests to avoid losing test coverage for
the other functions.

PR:		253984
Reviewed By:	ngie, dim
Differential Revision: https://reviews.freebsd.org/D29039
2021-04-20 01:46:43 +01:00
Alex Richardson 062293c2c4 Remove XFAIL from tests/lib/msun/lround_test:main
This test no longer fails after 3b00222f15.

PR:		205451
MFC after:	1 week
2021-04-15 16:28:09 +01:00
Alex Richardson 3f01d8c2fe Remove amd64 XFAIL from tests/lib/msun/fma_test:infinities
This test no longer fails after 3b00222f15.

PR:		205448
MFC after:	1 week
2021-04-15 16:28:08 +01:00
Alex Richardson 168234fa67 lib/msun: Exclude ignored-pragmas from -Werror
This avoids build failures due to the clang 12 warning:
    '#pragma FENV_ACCESS' is not supported on this target - ignored

Clang 12 currently emits this warning for all non-x86 architectures.
While this can result in incorrect code generation (e.g. on AArch64 some
exceptions are not raised as expected), this is a pre-existing issue and
we should not fail the build due to this warning.

Reviewed By:	dim, emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29743
2021-04-15 16:27:52 +01:00
Alex Richardson f33b4fa2f0 lib/msun/tests: Drop WARNS=6
This is the default already, so there is no need to override it.

Reported by:	kevans
2021-03-22 16:57:43 +00:00
Alex Richardson dbb2d6f5e1 lib/msun/tests: Re-enable csqrt_test on AArch64
The LLVM bug was fixed a long time ago and with D29076 this test actually
passes now.

Reviewed By:	andrew
Differential Revision: https://reviews.freebsd.org/D29092
2021-03-22 16:57:43 +00:00
Alex Richardson ce88eb476b Fix lib/msun/tests/csqrt_test on platforms with 128-bit long double
If long double has more than 64 mantissa bits, using uint64_t to hold the
mantissa bits will truncate the value and result in test failures. To fix
this problem use __uint128_t since all platforms that have
__LDBL_MANT_DIG__ > 64 also have compiler support for 128-bit integers.

Reviewed By:	rlibby
Differential Revision: https://reviews.freebsd.org/D29076
2021-03-22 16:57:43 +00:00
Alex Richardson 7f5693d053 Fix unused functions in invtrig_test.c
I only tested the WARNS=6 change on AArch64 and AMD64, but this file has
unused functions for architectures with LDBL_PREC == 53.

While touching this file change the LDBL_PREC == 53 checks to i386 checks.
The long double tests should only be disabled for i386 (due to the rather
odd rounding mode that it uses) not all architectures where long double
is the same as double.

PR:		205449
Fixes:		87d65c747a ("lib/msun: Allow building tests with WARNS=6")
Reported by:	Jenkins
2021-03-22 13:06:02 +00:00
Alex Richardson 6ccdee8ab5 lib/msun/tests: Add more debug output to fenv_test.c
Output a hex dump of the current fenv and the expected value to allow
comparing them without having to resort to interactive use of GDB.
2021-03-22 11:55:07 +00:00
Alex Richardson 2b9dbcd390 lib/msun/tests: Skip fenv_test:masking if exceptions can't be trapped
Some CPUs (e.g. AArch64 QEMU) cannot trap on floating point exceptions and
therefore ignore the writes to the floating point control register inside
feenableexcept(). If no exceptions are enabled after
feenableexcept(FE_ALL_EXCEPT), we can assume that the CPU does not
support exceptions and we can then skip the test.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D29095
2021-03-22 11:55:07 +00:00
Alex Richardson 87d65c747a lib/msun: Allow building tests with WARNS=6
The only change needed is to mark a few variables as static.
2021-03-22 11:55:07 +00:00
Alex Richardson b424e0038a Improve test messages for msun tests
Also print the mismatched values when numbers compare not equal.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D29091
2021-03-22 11:55:06 +00:00
Alex Richardson b358534ab1 Remove XFAILs from fmaxmin test
These appears to have been resolved by compiling the test with -fno-builtin
and/or using a newer compiler.

PR:		208703
Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28884
2021-03-22 11:55:06 +00:00
Alex Richardson 133bc64507 Convert the msun tests to ATF
This provides better error messages that just an assertion failure and
also makes it easier to mark individual tests as XFAIL.
It was also helpful when coming up with D28786 and D28787.

Differential Revision: https://reviews.freebsd.org/D28798
2021-03-22 11:55:06 +00:00
Dimitry Andric cf97d2a1da Build lib/msun tests with compiler builtins disabled
This forces the compiler to emit calls to libm functions, instead of
possibly substituting pre-calculated results at compile time, which
should help to actually test those functions.

Reviewed by:	emaste, arichardson, ngie
Differential Revision: https://reviews.freebsd.org/D28577
MFC after:	3 days
2021-02-23 21:10:01 +01:00
Alex Richardson f3f7b0dc06 lib/msun/ctrig_test: Print the mismatched values on failure
This test fails on aarch64 but debugging it is difficult without the
results being printed.

Now the failing AArch64 test prints:
root@freebsd-aarch64:/nfsroot/usr/tests/lib/msun # kyua debug ctrig_test:test_nan_inputs
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctan)(_d) (0 + -1 I) != expected (-0 + -1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctan fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctan)(_d) (0 + 1 I) != expected (-0 + 1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctan fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctanf)(_d) (0 + -1 I) != expected (-0 + -1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctanf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctanf)(_d) (0 + 1 I) != expected (-0 + 1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctanf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanh)(_d) (1 + 0 I) != expected (1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanh fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanhf)(_d) (1 + 0 I) != expected (1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanhf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanh)(_d) (-1 + 0 I) != expected (-1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanh fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanhf)(_d) (-1 + 0 I) != expected (-1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanhf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
ctrig_test:test_nan_inputs  ->  failed: 16 checks failed; see output for more details

Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28788
2021-02-23 09:39:40 +00:00
Alex Richardson 1ec3feb648 Update libm tests from NetBSD
I did this without a full vendor update since that would cause too many
conflicts. Since these files now almost match the NetBSD sources the
next git subtree merge should work just fine.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D28797
2021-02-22 17:41:04 +00:00
Alex Richardson a7b42c4b7f msun: ctanh/ctanhf: Import fix from musl libc
This applies musl commit b02eed9c4841913d690a2d0029737d72615384fe by
Szabolcs Nagy and updates the tests accordingly. This also allows
removing an XFAIL from the test.

musl commit message:

complex: fix ctanh(+-0+i*nan) and ctanh(+-0+-i*inf)

These cases were incorrect in C11 as described by
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1886.htm

PR: 217528

Reviewed By:	dim
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D28578
2021-02-15 22:55:12 +00:00
Dimitry Andric d3338f3355 Fix incorrect hypotl(3) result with subnormal numbers
This adjusts the factor used to scale the subnormal numbers, so it
becomes the right value after adjusting its exponent. Thanks to Steve
Kargl for finding the most elegant fix.

Also enable the hypot tests, and add a test case for this bug.

PR:		253313
MFC after:	1 week
2021-02-10 23:28:43 +01:00
Dimitry Andric ac76bc1145 Fix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10
This sprinkles a few strategic volatiles in an attempt to defeat clang's
optimization interfering with the expected floating-point exception
flags.

Reported by:	lwhsu
PR:		244732
MFC after:	3 days
2021-02-09 22:07:05 +01:00
Alex Richardson 892a05ee3a Avoid double output in fenv_test
This tests fork()s, so if there is still data in the stdout buffer on fork
it will print it again in the child process. This was happening in the
CheriBSD CI and caused the test to complain about malformed TAP output.

Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28397
2021-01-29 09:29:27 +00:00
Alex Richardson 4d2edf3af1 test_inf_inputs: Use atf_tc_expect_fail() instead of atf_tc_skip()
Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D28396
2021-01-29 09:28:40 +00:00
Alex Richardson d4a6843bb1 Update comment missed in 83ff5d5d98
Reported by:	jrtc27
2021-01-29 09:19:27 +00:00
Alex Richardson 83ff5d5d98 Un-XFAIL two tests with Clang > 10
SVN r343917 fixed this for in-tree clang, but when building with a newer
out-of-tree clang the test was still marked as XFAIL.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D28390
2021-01-28 17:24:24 +00:00
Alfredo Dal'Ava Junior 758f9acf8c msun tests: use standard floating-point exception flags on lrint and fenv tests
Some platforms have additional architecture-specific floating-point flags.
Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags,
so make sure to mask them appropriately.

This makes test pass on PowerPC64.

Reviewed by:	jhibbits, ngie
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D27202
2020-11-18 19:23:30 +00:00
Xin LI 941791759c Don't explicitly specify c99 or gnu99 as the default is now gnu99.
MFC after:	2 weeks
2020-08-17 05:57:02 +00:00
Mitchell Horne 2d143336de Enable long double tests on RISC-V
Some of the NetBSD contributed tests are gated behind the
__HAVE_LONG_DOUBLE flag. This flag seems to be defined only for
platforms whose long double is larger than their double. I could not
find this explicitly documented anywhere, but it is implied by the
definitions in NetBSD's sys/arch/${arch}/include/math.h headers, and the
following assertion from the UBSAN code:

  #ifdef __HAVE_LONG_DOUBLE
      long double LD;
      ASSERT(sizeof(LD) > sizeof(uint64_t));
  #endif

RISC-V has 128-bit long doubles, so enable the tests on this platform,
and update the comments to better explain the purpose of this flag.

Reviewed by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25419
2020-06-24 13:11:19 +00:00
Li-Wen Hsu 0fc06121ac Temporarily skip 2 failing tests after llvm10 import
PR:		244732
Sponsored by:	The FreeBSD Foundation
2020-03-11 12:43:54 +00:00
Li-Wen Hsu 24612bfd1f Unskip test cases from netbsd-tests by defining __HAVE_FENV
This unskips:
  - lib.libc.stdlib.strtod_test.strtod_round
  - lib.msun.fe_round_test.t_nofe_round

In lib/msun/tests/Makefile only define on fe_round_test.c because
lib.msun.ilogb_test.ilogb will get wrong results and needs more examination.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-08-31 20:45:45 +00:00
Dimitry Andric 740890be23 Partially revert r271349, which disabled the msun cexp test #4 on i386.
Ensure the expected result is stored first in a volatile variable with
the desired type.  This makes all the tests succeed.

Slightly changed from the original pull request, but functionally the
same.

Obtained from:	https://github.com/freebsd/freebsd/pull/401
Submitted by:	Moritz Buhl <gh@moritzbuhl.de>
PR:		191676
MFC after:	3 days
2019-06-01 20:08:10 +00:00
Dimitry Andric bc8fc00705 Amend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and
trig_test.reduction test cases to fail, if the fixes from r343916 have
not yet been applied to the base compiler.

Reported by:    lwhsu
PR:		234040
Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after:	1 week
2019-02-08 18:31:54 +00:00
Li-Wen Hsu 24df7b15fa Temporarily mark lib.msun.{cbrt_test.cbrtl_powl,trig_test.reduction}
expected failure after clang700-import merge

PR:		234040
Reviewed by:	ngie, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18938
2019-01-25 18:48:20 +00:00
Dimitry Andric b451efbedc Resolve conflicts between macros in fenv.h and ieeefp.h
This is a follow-up to r321483, which disabled -Wmacro-redefined for
some lib/msun tests.

If an application included both fenv.h and ieeefp.h, several macros such
as __fldcw(), __fldenv() were defined in both headers, with slightly
different arguments, leading to conflicts.

Fix this by putting all the common macros in the machine-specific
versions of ieeefp.h.  Where needed, update the arguments in places
where the macros are invoked.

This also slightly reduces the differences between the amd64 and i386
versions of ieeefp.h.

Reviewed by:	kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D15633
2018-05-31 20:22:47 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Ryan Libby fca37d4727 lib/msun: add more csqrt unit tests for precision and overflow
Reviewed by:	bde
Approved by:	markj (mentor)
Sponsored by:	Dell EMC Isilon
2017-08-29 22:37:24 +00:00
Enji Cooper b92e8635f9 Revert r321457
It doesn't fail after ^/head@r322855 (the releng_50 clang merge).

PR:	220989
MFC after:	2 months
MFC with:	r321369, r322855
2017-08-26 06:44:50 +00:00
Enji Cooper 9f27375481 Re-add #endif accidentally deleted in r321484
MFC after:	1 month
MFC with:	r321455, r321484
2017-07-25 16:57:25 +00:00
Enji Cooper db92647731 Only test ld_pi_odd with LDBL_MANT_DIG == 64 to fix the build
The empty (unimplemented) test inputs for sparc64 trigger a -Wtype-limits build
failure because nitems of an empty array is always false, i.e., deadcode.

MFC after:	1 month
MFC with:	r321455
Reported by:	Jenkins (sparc64 job)
2017-07-25 16:21:22 +00:00
Enji Cooper 82482c7c1f Mask issues with duplicate definitions for __fnstcw, __fldenv, and __fldcw on
i386 by ignoring -Wmacro-redefined.

This is a bandaid until the code is fixed and will be reverted before MFC.
2017-07-25 16:11:36 +00:00
Enji Cooper bc82a381be Mark :reduction as an expected failure
It fails with clang 5.0+.

PR:	220989
MFC after:	2 months
MFC with:	r321369
Reported by:	Jenkins
2017-07-25 03:56:42 +00:00
Enji Cooper 4580a78efd Convert lib/msun/trig_test from TAP to ATF format
Only expose :accuracy and :reduction if !i386, similar to before,
but more holistically to avoid future -Wunused issue with the unused
functions.

MFC after:	1 month
2017-07-25 03:55:44 +00:00
Enji Cooper fd5e9c331e Raise WARNS to 1
This will enable warnings with the msun tests.

MFC after:	1 month
2017-07-25 03:54:35 +00:00
Enji Cooper b97ee15f62 logarithm_test: assert that feclearexcept succeeds
This helps ensure that test preconditons are fulfilled.

MFC after:	3 days
Reported by:	Coverity
CID:		1346572
Sponsored by:	Dell EMC Isilon
2017-05-29 18:49:28 +00:00