Commit Graph

974 Commits

Author SHA1 Message Date
Steve Kargl
3bfc837685 sinpi,cospi,tanpi: float.h needed for week reference
The patch fixes the omission of '#include <float.h>', which is needed for
the weak reference on systems with LDBL_MANT_DIG == DBL_MANT_DIG.

PR:	218514
MFC after:	1 week
2021-10-29 03:15:19 +03:00
Steve Kargl
ca3d8cb087 lib/msun: Move the files to appropriate locations in the Makefile
Fixes:	dce5f3abed
PR:	218514
MFC after:	1 week
2021-10-27 01:34:12 +03:00
Konstantin Belousov
6312d14461 lib/msun/ld128/s_tanpil.c: make it compile.
Declare local, add missed ';'.
Name function properly.

Fixes:	dce5f3abed
Reviewed by:	kargl
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-10-27 01:34:12 +03:00
Steve Kargl
dce5f3abed [LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]
Both IEEE-754 2008 and ISO/IEC TS 18661-4 define the half-cycle
trignometric functions cospi, sinpi, and tanpi.  The attached
patch implements cospi[fl], sinpi[fl], and tanpi[fl].  Limited
testing on the cospi and sinpi reveal a max ULP less than 0.89;
while tanpi is more problematic with a max ULP less than 2.01
in the interval [0,0.5].  The algorithms used in these functions
are documented in {ks}_cospi.c, {ks}_sinpi.c, and s_tanpi.c.

Note.  I no longer have access to a system with ld128 and
adequate support to compile and test the ld128 implementations
of these functions.  Given the almost complete lack of input from
others on improvements to libm, I doubt that anyone cares.  If
someone does care, the ld128 files contain a number of FIXME comments,
and in particular, while the polynomial coefficients are given
I did not update the polynomial algorithms to properly use the
coefficients.

PR:	218514
MFC after:	2 weeks
2021-10-26 02:50:20 +03:00
Warner Losh
3550a49f68 msun: Add copyright notices
These files were copied from MUSL. Add the standard copyright notice and
SPDX-License-Identifier: MIT consistent with our new draft license
policy. It reads word for word the same as the MIT license on the SPDX
web site. Add a pointer to the MUSL COPYIRGHT file which contains a list
of all authors of MUSL.

Sponsored by:		Netflix
Noticed by:		Steve Kargl
2021-10-22 22:00:54 -06:00
Mark Murray
292815eac6 Fix powf().
Summary:
From Steve Kargl:

Paul Zimmermann has identified a bug in Openlibm's powf(),
which is identical to FreeBSD's libm.  Both derived from
fdlibm. https://github.com/JuliaMath/openlibm/issues/212.

Consider

% cat h.c
int
main(void)
{
  float x, y, z;
  x =  0x1.ffffecp-1F;
  y = -0x1.000002p+27F;
  z =  0x1.557a86p115F;
  printf("%e %e %e <-- should be %e\n", x, y, powf(x,y), z);
  return 0;
}

% cc -o h -fno-builtin h.c -lm && ./h
9.999994e-01 -1.342177e+08 inf <-- should be 5.540807e+34

Reviewers: manu

Subscribers: imp, andrew, emaste

Differential Revision: https://reviews.freebsd.org/D31865
2021-09-06 18:51:31 +01:00
Gordon Bergling
c5cbef2f85 math(3): Use the .Fa macro for function arguments
.Fa is the suitable macro for functions in comparsion to the
.Ar macro, which should be used for commandline arguments.

While here, fix some mandoc warnings.

Reviewed by:	imp (earlier version)
Obtained from:	OpenBSD (in partial)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D31090
2021-07-09 19:51:44 +02:00
Dimitry Andric
0bcd49c13a Work around bogus old gcc "initializer element is not constant" error
After df3b437c1e, older gcc's such as
4.2.1 (still used on earlier branches for e.g. mips and powerpc) and
6.3.0 (still used for some cross-builds) started throwing bogus errors
like:

In file included from /workspace/src/lib/msun/src/s_llround.c:11:0:
/workspace/src/lib/msun/src/s_lround.c:54:31: error: initializer element is not constant
 static const type dtype_min = type_min - 0.5;
                               ^~~~~~~~
/workspace/src/lib/msun/src/s_lround.c:55:31: error: initializer element is not constant
 static const type dtype_max = type_max + 0.5;
                               ^~~~~~~~

Since 'type_min' and 'type_max' are constants declared just above these
lines this error is nonsensical, but older gcc's are not smart enough.

Work around the error by reusing the (type)DTYPE_MIN and (type)DTYPE_MAX
macros, so I can MFC this right away, unbreaking a few stable builds.

MFC after:	immediately
2021-06-25 20:43:20 +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
Justin Hibbits
2b9a828c99 Set default SPE FP environment 2021-05-29 21:53:35 -05:00
Justin Hibbits
6640579610 msun fixes for SPE
Summary:
Fix FPU exception management for powerpcspe.  Bits are in a different place from
the standard FPSCR, so we need to handle the shifting differences.  Also,
there's no concept of a "software exception" raise, so we need to do exceptional
math to trigger the exception from software.

Reviewed By: alfredo
Differential Revision: https://reviews.freebsd.org/D22824
2021-05-05 20:57:33 -05: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
Dimitry Andric
bae9fd0b33 Only use -fp-exception-behavior=maytrap on x86, for now
After 3b00222f15, it turns out that clang only supports strict
floating point semantics for SystemZ and x86 at the moment, while for
other architectures it is still experimental.

Therefore, only use -fp-exception-behavior=maytrap on x86 for now,
otherwise this option results in "error: overriding currently
unsupported use of floating point exceptions on this target
[-Werror,-Wunsupported-floating-point-opt]" on other architectures.

Fixes:		3b00222f15
PR:		254911
MFC after:	1 week
2021-04-10 16:02:58 +02:00
Dimitry Andric
3b00222f15 Avoid raising unexpected floating point exceptions in libm
When using clang with x86_64 CPUs that support AVX, some floating point
transformations may raise exceptions that would not have been raised by
the original code. To avoid this, use the -fp-exception-behavior=maytrap
flag, introduced in clang 10.0.0.

In particular, this fixes a number of test failures with ctanhf(3) and
ctanf(3), when libm is compiled with -mavx. An unexpected FE_INVALID
exception is then raised, because clang emits vdivps instructions to
perform certain divides. (The vdivps instruction operates on multiple
single-precision float operands simultaneously, but the exceptions may
be influenced by unused parts of the XMM registers. In this particular
case, it was calculating 0 / 0, which results in FE_INVALID.)

If -fp-exception-behavior=maytrap is specified however, clang uses
vdivss instructions instead, which work on one operand, and should not
raise unexpected exceptions.

Reported by:	olivier
Reviewed by:	arichardson
PR:		254911
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29686
2021-04-10 13:59:57 +02:00
Dimitry Andric
7702d940ec Avoid -pedantic warnings about using _Generic in __fp_type_select
When compiling parts of math.h with clang using a C standard before C11,
and using -pedantic, it will result in warnings similar to:

bug254714.c:5:11: warning: '_Generic' is a C11 extension [-Wc11-extensions]
  return !isfinite(1.0);
          ^
/usr/include/math.h:111:21: note: expanded from macro 'isfinite'
                    ^
/usr/include/math.h:82:39: note: expanded from macro '__fp_type_select'
                                      ^

This is because the block that enables use of _Generic is conditional
not only on C11, but also on whether the compiler advertises support for
C generic selections via __has_extension(c_generic_selections).

To work around the warning without having to pessimize the code, use the
__extension__ keyword, which is supported by both clang and gcc. While
here, remove the check for __clang__, as _Generic has been supported for
a long time by gcc too now.

Reported by:	yuri
PR:		254714
MFC after:	1 week
2021-04-08 18:20:32 +02:00
Alex Richardson
dd5ed53a2f RISC-V: Fix feenableexcept return value
The man page says "The feenableexcept(), fedisableexcept(), and
fegetexcept() functions return a bitmap of the exceptions that were
unmasked prior to the call.", so we should return zero not -1.

Reviewed By:	mhorne
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D29386
2021-03-25 11:16:20 +00:00
Alex Richardson
15211f1950 Silence unused parameter warnings in the RISC-V fenv.h
After increasing the lib/msun/tests WARNS to 6, this triggers a
compilation error for RISC-V.

Fixes:		87d65c747a ("lib/msun: Allow building tests with WARNS=6")
Reported by:	Jenkins
2021-03-22 17:49:24 +00: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
Alex Richardson
05eac56a04 lib/msun: Fix x86 GCC6 build after 221622ec0c
Apparently GCC only supports arithmetic expressions that use static
const variables in initializers starting with GCC8. To keep older
versions happy use a macro instead.

Fixes:		221622ec0c ("lib/msun: Avoid FE_INEXACT for x86 log2l/log10l")
Reported by:	Jenkins
Reviewed By:	imp
Differential Revision: https://reviews.freebsd.org/D29233
2021-03-12 18:44:44 +00:00
Alex Richardson
34cc08e336 Save all fpcr/fpsr bits in the AArch64 fenv_t
The existing code masked off all bits that it didn't know about. To be
future-proof, we should save and restore the entire fpcr/fpsr registers.
Additionally, the existing fesetenv() was incorrectly setting the rounding
mode in fpsr instead of fpcr.

This patch stores fpcr in the high 32 bits of fenv_t and fpsr in the low
bits instead of trying to interleave them in a single 32-bit field.

Technically, this is an ABI break if you re-compile parts of your code or
pass a fenv_t between DSOs that were compiled with different versions
of fenv.h. However, I believe we should fix this since the existing code
was broken and passing fenv_t across DSOs should rarely happen.

Reviewed By:	andrew
Differential Revision: https://reviews.freebsd.org/D29160
2021-03-12 17:01:41 +00:00
Alex Richardson
221622ec0c lib/msun: Avoid FE_INEXACT for x86 log2l/log10l
This fixes tests/lib/msun/logarithm_test after compiling the test with
-fno-builtin (D28577). Adding invln10_lo + invln10_10 results in
FE_INEXACT (for all inputs) and the same for the log2l invln2_lo + invln2_hi.
This patch avoids FE_INEXACT (for exact results such as 0) by defining a
constant and using that.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D28786
2021-03-08 09:39:32 +00:00
Alex Richardson
f5542795b9 s_scalbn.c: Add missing float.h include
This caused LDBL_MANT_DIG to not be defined and therefore the scalbnl
alias was not being emitted for double==long double platforms.

Fixes:		760b2ffc ("Update scalbn* functions to the musl versions")
Reported by:	Jenkins
2021-03-01 14:22:47 +00:00
Alex Richardson
760b2ffc55 Update scalbn* functions to the musl versions
The only diff compared to musl is a minor change to scalbnl() to replace
musl's union ldshape with union IEEEl2bits.
This fixes the scalbn tests on non-x86 (since x86 has an assembly version
that is used instead).

Musl commit messages:
commit 8c44a060243f04283ca68dad199aab90336141db
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Mon Apr 3 02:38:13 2017 +0200

    fix scalbn when result is in the subnormal range

    in nearest rounding mode scalbn could introduce double rounding error
    when an intermediate value and the final result were both in the
    subnormal range e.g.

      scalbn(0x1.7ffffffffffffp-1, -1073)

    returned 0x1p-1073 instead of 0x1p-1074, because the intermediate
    computation got rounded to 0x1.8p-1023.

    with the fix an intermediate value can only be in the subnormal range
    if the final result is 0 which is correct even after double rounding.
    (there still can be two roundings so signals may be raised twice, but
    that's only observable with trapping exceptions which is not supported.)

commit 2eaed464e2080d8321d3903b71086a1ecfc4ee4a
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Wed Sep 4 15:52:54 2013 +0000

    math: use float_t and double_t in scalbnf and scalbn

    remove STRICT_ASSIGN (c99 semantics is assumed) and use the conventional
    union to prepare the scaling factor (so libm.h is no longer needed)

commit 1b77b9072f374bd26eb0574b83a0d5f18d75ec60
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Thu Aug 15 10:07:46 2013 +0000

    math: minor scalbn*.c simplification

commit c4359e01303da2755fe7e8033826b132eb3659b1
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Tue Nov 13 10:55:35 2012 +0100

    math: excess precision fix modf, modff, scalbn, scalbnf

    old code was correct only if the result was stored (without the
    excess precision) or musl was compiled with -ffloat-store.
    now we use STRICT_ASSIGN to work around the issue.
    (see note 160 in c11 section 6.8.6.4)

commit 666271c105e4137bdfa195e217799d74143370d4
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Tue Nov 13 10:30:40 2012 +0100

    math: fix scalbn and scalbnf on overflow/underflow

    old code was correct only if the result was stored (without the
    excess precision) or musl was compiled with -ffloat-store.
    (see note 160 in n1570.pdf section 6.8.6.4)

commit 8051e08e10d2b739fcfcbc6bc7466e8d77fa49f1
Author: nsz <nsz@port70.net>
Date:   Mon Mar 19 10:54:07 2012 +0100

    simplify scalbn*.c implementations

    The old scalbn.c was wrong and slow, the new one is just slow.
    (scalbn(0x1p+1023,-2097) should give 0x1p-1074, but the old code gave 0)

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D28872
2021-03-01 12:53:45 +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
Steve Kargl
93fc678965 Fix incorrect powf(3) result with x near 1 and |y| much larger than 1
This adjusts the check to trigger overflow/underflow to a slightly lower
value.

Before: powf(9.999995e-01, -1.342177e+08) -> inf
After:  powf(9.999995e-01, -1.342177e+08) -> 1.858724e+31

MFC after:	1 week
2021-02-08 20:48:43 +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
Conrad Meyer
78599c32ef Add CFI start/end proc directives to arm64, i386, and ppc
Follow-up to r353959 and r368070: do the same for other architectures.

arm32 already seems to use its own .fnstart/.fnend directives, which
appear to be ARM-specific variants of the same thing.  Likewise, MIPS
uses .frame directives.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D27387
2020-12-05 00:33:28 +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
Alfredo Dal'Ava Junior
e7bd4f846f [POWERPC] msun: fix incorrect flag in fesetexceptflag
Fix incorrect mask being used when FE_INVALID bit is wanted by user.
The problem was noticed thanks to msun fenv tests.

Reviewed by:	jhibbits, luporl
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D27201
2020-11-17 12:36:59 +00:00
Warner Losh
e369c79ca0 Remove intel compiler support from math.h
The intel compiler support has badly decayed over the years. Stop
pretending that we support it. Note, I've stopped short of requiring
gcc builtin support with this commit since other compilers may be used
to build non-base software and we need to support those so more
investigation is needed before simplifying further.
2020-10-24 23:21:22 +00:00