Commit graph

1028 commits

Author SHA1 Message Date
Enji Cooper 5bd43b0033 Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
of the clang version

This works around breakage on ^/stable/10 when running installworld from
a ^/stable/10 host where the test wouldn't be compiled on the first
go-around and would be missing when make installworld is run.

MFC after:	1 week
PR:		208703
Reported by:	emaste
Sponsored by:	Dell EMC Isilon
2017-01-15 09:05:26 +00:00
Enji Cooper ee5d5813c0 fmaxmin_test still fails with clang 3.9.x.. bypass the test
MFC after:	3 days
PR:		208703
Sponsored by:	Dell EMC Isilon
2017-01-13 04:21:09 +00:00
Enji Cooper cdebaff820 Upgrade NetBSD tests to 01.11.2017_23.20 snapshot
This contains some new testcases in /usr/tests/...:

- .../lib/libc
- .../lib/libthr
- .../lib/msun
- .../sys/kern

Tested on:	amd64, i386
MFC after:	1 month
2017-01-13 03:33:57 +00:00
Ed Maste 2737721014 libm: remove duplicate version script entries
These symbols already appear in the common lib/msun/Symbol.map.
Duplicate entries produce an error with LLVM's LLD linker.

Reviewed by:	br
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8627
2016-11-29 18:40:24 +00:00
Ruslan Bukin 7804dd5212 Add full softfloat and hardfloat support for RISC-V.
Hardfloat is now default (use riscv64sf as TARGET_ARCH
for softfloat).

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D8529
2016-11-16 15:21:32 +00:00
Ruslan Bukin 2ad1d09f16 o Add support for long double.
o Add support for latest RISC-V GNU toolchain.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-11-03 13:06:17 +00:00
Ed Maste dba5d1ca17 libm: add braces around initialization of subobjects
This cleans up a warning when building libm at higher WARNS levels and
makes the intent more clear. By the C standard the values are assigned
to subobject members in order so this change introduces no functional
change. (6.7.9 20)

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8333
2016-11-01 15:11:10 +00:00
Ruslan Bukin 5bca221511 Add full softfloat and hardfloat support for MIPS.
This adds new target architectures for hardfloat:
mipselhf mipshf mips64elhf mips64hf.

Tested in QEMU only.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D8376
2016-10-31 15:33:58 +00:00
Justin Hibbits dc9b124d66 Create a new MACHINE_ARCH for Freescale PowerPC e500v2
Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU.  The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive.  Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement.  setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).

Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.

Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.

Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used.  However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.

Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI.  Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.

Reviewed By:	bdrewery, imp
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D5683
2016-10-22 01:57:15 +00:00
Ruslan Bukin fae95359ee Don't use fmaxl/fminl on platforms with no long double support,
use fmax/fmin instead.

This fixes fmaxmin test failure on MIPS64.

Reviewed by:	emaste
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D8216
2016-10-11 20:31:59 +00:00
Ed Maste a01a51a352 libm: remove unused variables
Sponsored by:	The FreeBSD Foundation
2016-10-05 17:04:58 +00:00
Ed Maste cf825f93cc libm: remove unused variables for LDBL_MANT_DIG != 113
Sponsored by:	The FreeBSD Foundation
2016-09-30 20:20:07 +00:00
Ed Maste d6e65178c6 libm: simplify i387 subdir logic with make's :S substitution 2016-09-28 17:44:03 +00:00
Ed Maste dcdfa506cc libm: fix some unused variable (rcsid) and dangling else warnings
s_{fabs,fmax,logb,scalb}{,f,l}.c may be built elsewhere with a higher
WARNS setting.

Reviewed by:	ed
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8061
2016-09-28 14:48:34 +00:00
Bruce Evans f776d19f07 Oops, the previous i386 version of e_fmodf.S and e_fmodl.S was
actually the amd64 version.
2016-09-04 15:08:14 +00:00
Bruce Evans 5432c3bec3 Disconnect the "optimized" asm variants of cos(), sin() and tan() from
the build on i386.  Leave them in the source tree for regression tests.

The asm functions were always much less accurate (by a factor of more
than 10**18 in the worst case).  They were faster on old CPUs.  But
with each new generation of CPUs they get relatively slower.  The
double precision C version's average advantage is about a factor of 2
on Haswell.

The asm functions were already intentionally avoided in float and long
double precision on i386 and in all precisions on amd64.  Float
precision and amd64 give larger advantages to the C version.  The long
double precision C code and compilers' understanding of long double
precision are not so good, so the i387 is still slightly faster for
long double precision, except for the unimportant subcase of huge args
where the sub-optimal C code now somehow beats the i387 by about a
factor of 2.
2016-09-04 14:12:19 +00:00
Bruce Evans 83e449a402 Add asm versions of fmod(), fmodf() and fmodl() on amd64. Add asm
versions of fmodf() amd fmodl() on i387.

fmod is similar to remainder, and the C versions are 3 to 9 times
slower than the asm versions on x86 for both, but we had the strange
mixture of all 6 variants of remainder in asm and only 1 of 6
variants of fmod in asm.
2016-09-04 12:22:14 +00:00
Bruce Evans a4c138885e Fix missing fmodl() on arches with 53-bit long doubles.
PR:		199422, 211965
MFC after:	1 week
2016-09-04 12:01:32 +00:00
Enji Cooper 637cce3a32 MFhead @ r305314 2016-09-03 00:50:18 +00:00
Enji Cooper 7a83ecc454 Skip :test_large on i386
More assertions are failing on ^/head now.

PR:	205446
Sponsored by:	EMC / Isilon Storage Division
2016-09-02 08:17:43 +00:00
Enji Cooper 09797f9dce Adjust CFLAGS for fmod_test so it can find isqemu.h
Sponsored by: EMC / Isilon Storage Division
2016-08-13 01:40:08 +00:00
Bryan Drewery 2af16ec8f2 Revert r298434 which should be fixed by r301287, r301394, and r301403.
PR:	208703, 208963
2016-08-08 17:59:59 +00:00
Edward Tomasz Napierala b8f41779a2 Fix frexpl() declaration to not include the field name.
MFC after:	1 month
2016-06-09 20:49:26 +00:00
Warner Losh 2c0e9e2a09 Make armv6 hard float abi by default. Kill armv6hf.
Allow CPUTYPE=soft to build the current soft-float abi libraries.
Add UPDATING entry to announce this.

Approved by: re@ (gjb)
2016-05-18 06:01:18 +00:00
Enji Cooper 430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Pedro F. Giffuni 75f46cf6c8 lib: minor spelling fixes in comments.
No functional change.
2016-05-01 19:37:33 +00:00
Enji Cooper ca3ce56474 Completely disable fmaxmin_test (follow up to r297952)
COMPILER_TYPE/COMPILER_VERSION doesn't get passed down properly at
buildworld/installworld with older build hosts

MFC after: never
PR: 208703, 208963
Reported by: Jenkins
Sponsored by: EMC / Isilon Storage Division
2016-04-21 19:59:55 +00:00
Glen Barber 0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
Enji Cooper 47754aa240 Disable fmaxmin_test when compiling it with clang 3.8.0
The testcase always fails today due to how C11 7.6.1/2 is interpreted
with clang 3.8.0 when combined with "#pragma STDC FENV_ACCESS ON".

This testcase passes with clang <3.8.0 and gcc, so continue testing it
with those compiler combinations

More intelligent discussion on the issue is in the PR

MFC after: never
PR: 208703
Sponsored by: EMC / Isilon Storage Division
2016-04-14 04:40:31 +00:00
Glen Barber a123f26e92 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-12 17:00:13 +00:00
Enji Cooper 306c3c4d90 Fix appending -O0 to CFLAGS
The previous method would completely nerf CFLAGS once bsd.progs.mk had
recursed into the per-PROG logic and make the CFLAGS for tap testcases
to -O0, instead of appending to CFLAGS for all of the tap testcases.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-04-11 21:15:48 +00:00
Glen Barber d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Bryan Drewery 59f6130d2a Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally.
Sponsored by:	EMC / Isilon Storage Division
2016-03-26 03:46:12 +00:00
Glen Barber 7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery 15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber b655ec9752 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-06 04:13:17 +00:00
Dimitry Andric 82aa34e6fa Merge ^/head r296007 through r296368. 2016-03-03 23:15:46 +00:00
Glen Barber 52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Nathan Whitehorn f0e6a4d318 Make FPSCR definition endian clean.
PR:		207526
Submitted by:	Simon Byrne
Obtained from:	Julia
MFC after:	1 month
2016-02-26 20:25:26 +00:00
Glen Barber c389411c8a Remove libc, librtld_db, libthr packages, and further increase
the constraints on what needs to be installed in a specific to
maintain consistency during upgrades.

Create a new clibs package containing libraries that are needed
as a bare minimum for consistency.

With much help and input from:	kib
Sponsored by:	The FreeBSD Foundation
2016-02-05 21:01:08 +00:00
Glen Barber a70cba9582 First pass through library packaging.
Sponsored by:	The FreeBSD Foundation
2016-02-04 21:16:35 +00:00
Glen Barber 43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Dimitry Andric 752d00608c Merge ^/head r294777 through r294960. 2016-01-27 22:52:20 +00:00
Ruslan Bukin 4bf1032a04 Add fenv.c for RISC-V. Copied from MIPS. 2016-01-26 14:40:41 +00:00
Andrew Turner 1637b1642d Disable building the csqrt_test test on arm64, it hits an assert in
llvm 3.8.
2016-01-11 21:29:36 +00:00
Enji Cooper 194b8d633f Use j instead of a hardcoded index (9) and increment it after
running the NaNs testcases

MFC after: 3 days
Pointyhat to: ngie
Sponsored by: EMC / Isilon Storage Division
2015-12-23 09:11:18 +00:00
Enji Cooper 8a7d0e8ce3 Integrate the remaining tools/regression/lib/msun testcases into the
FreeBSD test suite under lib/msun/tests

MFC after: 3 weeks
X-MFC with: r292328
Sponsored by: EMC / Isilon Storage Division
2015-12-20 05:06:44 +00:00
Enji Cooper 4dc607e7f2 Integrate a number of testcases from tools/regression/lib/msun
into the FreeBSD test suite

There's no functional change with these testcases; they're purposely
being left in TAP format for the time being

Other testcases which crash on amd64/i386 as-is have not been
integrated yet (they need to be retested on a later version of
CURRENT, as I haven't used i386 in some time)

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2015-12-16 09:11:11 +00:00
Ruslan Bukin 1fdcc5e5c0 Start support for the RISC-V 64-bit architecture developed by UC Berkeley.
RISC-V is a new ISA designed to support computer research and education, and
is now become a standard open architecture for industry implementations.

This is a minimal set of changes required to run 'make kernel-toolchain'
using external (GNU) toolchain.

The FreeBSD/RISC-V project home: https://wiki.freebsd.org/riscv.

Reviewed by:	andrew, bdrewery, emaste, imp
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D4445
2015-12-11 22:55:23 +00:00
Bryan Drewery 3c89d6b0e3 Don't override LIB*DIR variables from src.libnames.mk.
In some cases switch to the LIB*SRCDIR value.

These recently were defined in r291327 and r291619.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 22:20:04 +00:00
Bryan Drewery 7b3ea376a2 META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host.
This both avoids some dependencies on xinstall.host and allows
bootstrapping on older releases to work due to lack of at least 'install -l'
support.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:10:28 +00:00
Enji Cooper fdb319ca66 Bump .Dd 2015-11-09 10:41:27 +00:00
Enji Cooper 6922f80018 Document powl(3)
PR: 191751
Sponsored by: EMC / Isilon Storage Division
2015-11-09 10:40:16 +00:00
Andrew Turner 2dac22dcf3 We have long double on arm64, and the tests pass so enable them.
Sponsored by:	ABT Systems Ltd
2015-10-31 10:16:44 +00:00
Enji Cooper b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Dimitry Andric a679d056de In libm's exp2(3), avoid left-shifting a negative integer, which is
undefined.  Replace it with the intended value, in a defined way.

Reviewed by:	bde
MFC after:	3 days
2015-08-09 10:00:13 +00:00
Baptiste Daroussin 59a046067a .ie is not supposed to be used in manpages
Submitted by:	carsten.kunze@arcor.de
2015-07-14 15:21:00 +00:00
Ian Lepore cbc120b22c Fix compilation when the armv6 world is being compiled without hw floating
point support.  The fenv-vfp.c file overrides -mfloat-abi so it can use
floating point instructions if it detects support at runtime.  Make it also
override -mfpu in case the user has set -mfpu=none.
2015-06-24 18:29:34 +00:00
Simon J. Gerraty 2ef6d5a7b9 new depends 2015-06-16 23:37:19 +00:00
Tijl Coosemans 65c323f2ac Follow up to r284427: fix NaN mixing for ctanhf too. 2015-06-15 20:47:26 +00:00
Tijl Coosemans 68b433d790 - Change comments to be more consistent with s_ccosh.c and s_csinh.c.
- Fix a case where NaNs were not mixed correctly and signalling NaNs were
  not converted to quiet NaNs.
- Eliminate two negations from ctan(z).

In collaboration with:	bde
2015-06-15 20:40:44 +00:00
Tijl Coosemans f0f050e0f9 Fix some exceptional cases where the sign of the result is unspecified
but must still satisfy csinh(conj(z)) == conj(csinh(z)) and csinh(-z) ==
-csinh(z).  This allows eliminating two negations from csin(z).

In collaboration with:	bde
2015-06-15 20:16:53 +00:00
Tijl Coosemans db7548d040 Fix some exceptional cases where the sign of the result is unspecified
but must still satisfy ccosh(conj(z)) == conj(ccosh(z)) and ccosh(-z) ==
ccosh(z).

In collaboration with:	bde
2015-06-15 20:11:06 +00:00
Baptiste Daroussin 18b2ee82db Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Baptiste Daroussin 4232f82668 Enforce overwritting SHLIBDIR
Since METAMODE has been added, sys.mk loads bsd.mkopt.mk which ends load loading
bsd.own.mk which then defines SHLIBDIR before all the Makefile.inc everywhere.

This makes /lib being populated again.

Reported by:	many
2015-06-15 15:34:20 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty bd831db65c Misc fixes from projects/bmake
Differential Revision:       D2748
Reviewed by: brooks imp
2015-06-11 21:13:05 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Steve Kargl 5b3a5f8343 In r279493, the functions pzero[f](), qzero[f], pone[f](),
and qone[f]() were marked as __inline, but their forward
declarations were not updated.  Fix the forward declarations
to match the actual function declarations.

Requested by:	 bde
2015-05-17 16:27:06 +00:00
Warner Losh c6b992ed3a The presence/absence of CPU features should be tested with
MACHINE_CPUARCH or MACHINE_ARCH, not MACHINE. The latter is for kernel
only things. Also, I think this should be unconditional since all our
architectures have long double support, but I don't have time to test
that thoroughly so just add a comment to that effect.
2015-04-28 14:14:06 +00:00
Enji Cooper b18bade8c2 Remove per-architecture checks for enabling HAVE_FENV_H
The conditional came from NetBSD, where only select architectures have this
header/support

All architectures on FreeBSD have the necessary support though, so the
conditional's completely unnecessary

make tinderbox done on all architectures (including arm64, where the issue
occurred before) this time

X-MFC with: r282057, r282092
MFC after: 6 days
2015-04-27 18:01:52 +00:00
Andrew Turner 4e78be73ba Correct the spelling of MACHINE_CPUARCH, MACHINE_CPU is not set on arm64. 2015-04-27 13:57:39 +00:00
Enji Cooper 1119ece4d3 Build/install libc, librt, libthr, and msun NetBSD test suites on all
architectures

MFC after: 1 week
2015-04-27 06:49:27 +00:00
Baptiste Daroussin 0af928e203 mdoc: fix function declaration 2015-04-26 11:35:36 +00:00
Baptiste Daroussin fbe7ee53da mdoc: remove empty line 2015-04-26 11:35:07 +00:00
Baptiste Daroussin 84413e5425 Remove end of line whitespace 2015-04-26 11:30:27 +00:00
Andrew Turner f734628543 Add the fe* symbols to libm for arm64.
Sponsored by:	The FreeBSD Foundation
2015-03-31 19:07:28 +00:00
Ed Maste 58853f4fb9 Correct mrs_fpcr and mrs_fpsr macros in arm64 fenv.h
Submitted by:	andrew
Sponsored by:	The FreeBSD Foundation
2015-03-30 16:42:08 +00:00
Andrew Turner 8daa81674e Start to import support for the AArch64 architecture from ARM. This change
only adds support for kernel-toolchain, however it is expected further
changes to add kernel and userland support will be committed as they are
reviewed.

As our copy of binutils is too old the devel/aarch64-binutils port needs
to be installed to pull in a linker.

To build either TARGET needs to be set to arm64, or TARGET_ARCH set to
aarch64. The latter is set so uname -p will return aarch64 as existing
third party software expects this.

Differential Revision:	https://reviews.freebsd.org/D2005
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2015-03-19 13:53:47 +00:00
Steve Kargl 186f620727 According to POSIX.1-2008, the Bessel functions of second kind
should raise a divide-by-zero floating point exception for x = +-0
and an invalid floating point exception for x < 0 including x = -Inf.
Update the code to raise the exception and update the documentation
with hopefully better description of the behavior.

Reviewed by:	bde (code only)
2015-03-10 17:10:54 +00:00
Steve Kargl a737ef56ab Give compilers a stronger hint to inline the functions
pzero[f], qzero[f], pone[f], and qone[f].  While here
fix the function declarations in accordance with style(9).
2015-03-01 20:32:47 +00:00
Steve Kargl 8192c85cb3 When j0() and j1() were converted to j0f() and j1f(), the threshold
values for the different invervals were not converted correctly.
Adjust the threshold values to values, which should agree with the
comments.

Reported by:	cognet (j1f only)
Discussed with: pfg, bde
Reviewed by:	bde
2015-03-01 20:26:03 +00:00
Pedro F. Giffuni d300dc2302 msun: drop unnecessary checks (part 2).
Drop an unnecessary check in some calculations. The check
would have Coverity falsely conclude that a variable could
be left undefined.
2015-02-24 16:45:16 +00:00
Pedro F. Giffuni 8617260a03 msun: drop unnecessary checks.
Drop an unnecessary check in some calculations. The check
would have Coverity falsely conclude that variables could
be left undefined.

Discussed with:	kargl, bde
Reviewed by:	bde
2015-02-22 01:15:09 +00:00
Steve Kargl dc98c00464 Truncate the exponent 'n' of type long to a domain contained
within [INT_MIN, INT_MAX] where the magnitude of the lower
and upper bounds are sufficiently large to span the range of
scalbn[fl].

While here, remove the GNU style bug in the function declarations.

Reviewed by:	bde, pfg
2015-02-07 00:38:18 +00:00
Pedro F. Giffuni 5b3ddf0928 scanblnl: drop extra braces.
Pointed out by:	bde
2015-02-03 16:16:52 +00:00
Pedro F. Giffuni 73c031c5d4 Reduce confusion in scalbnl() family of functions.
The changes unrelated to the bug in r277948 made
the code very difficult to understand to both
coverity and regular humans so take a step back
to something that is much easier to understand
for both and follows better the original code.

CID:	1267992, 1267993, 1267994
Discussed with:	kargl
2015-02-03 14:17:29 +00:00
Pedro F. Giffuni 311449a4e3 msun: use previously ignored value.
This fixes evaluation of exceptional values in scalblnl().
While here, simplify the code as suggested by Bruce Evans.

Reported by:	clang static analyzer
MFC after:	1 week
2015-01-30 19:19:03 +00:00
Joel Dahl f7e00d4bbd mdoc: remove EOL whitespace. 2014-12-29 13:50:59 +00:00
Joel Dahl c09eb46601 mdoc: improvements to SEE ALSO. 2014-12-27 08:22:58 +00:00
Joel Dahl 7161cdb37b Minor Xr fix. 2014-12-26 09:18:33 +00:00
Ed Schouten 799cf446be Clarify to explain that C99 conforming compilers don't need CMPLX*().
Discussed with: kargl@
2014-12-24 10:13:53 +00:00
Ed Schouten 2cec876a59 Rename cpack*() to CMPLX*().
The C11 standard introduced a set of macros (CMPLX, CMPLXF, CMPLXL) that
can be used to construct complex numbers from a pair of real and
imaginary numbers. Unfortunately, they require some compiler support,
which is why we only define them for Clang and GCC>=4.7.

The cpack() function in libm performs the same task as CMPLX(), but
cannot be used to generate compile-time constants. This means that all
invocations of cpack() can safely be replaced by C11's CMPLX(). To keep
the code building with GCC 4.2, provide copies of CMPLX() that can at
least be used to generate run-time complex numbers.

This makes it easier to build some of the functions outside of libm.
2014-12-16 09:21:56 +00:00
Steve Kargl 5dc4735cb3 Adjust the |x| small limit from 0x1p-7 to 0x1p-9. This
adjustment increases the number of correctly rounded
cases within the interval on i386.

Requested by:	bde
2014-12-08 15:47:52 +00:00
Steve Kargl 2656e946c8 Update the constants associated with the evaluation of j0f(x)
for |x| small.

While here, remove the explicit cast of 0.25 to float.  Replace
a multiplication involving 0.25 by a division using an integer
constant 4.  Make a similar change in j0() to minimize the diff.

Suggested by:	bde
2014-12-05 19:00:55 +00:00
Steve Kargl 668986107d Fix a 20+ year bug by using an appropriate constant for
the transition from one asymptotic approximation to another
for the zeroth order Bessel and Neumann functions.

Reviewed by:	bde
2014-12-04 15:57:58 +00:00
Baptiste Daroussin 6b129086dc Convert libraries to use LIBADD
While here reduce a bit overlinking
2014-11-25 11:07:26 +00:00
Ed Maste 294246bb7d Revert r274772: it is not valid on MIPS
Reported by:	sbruno
2014-11-25 03:50:31 +00:00
Ed Maste 688fd61ae8 Use canonical __PIC__ flag
It is automatically set when -fPIC is passed to the compiler.

Reviewed by:	dim, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1179
2014-11-21 02:05:48 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Enji Cooper 4cef7be5c3 Add reachover Makefiles for contrib/netbsd-tests/lib/librt
A variant of this code has been tested on amd64/i386 for some time by
EMC/Isilon on 10-STABLE/11-CURRENT. It builds on other architectures, but the
code will remain off until it's proven it works on virtual hardware or real
hardware on other architectures

Sponsored by: EMC / Isilon Storage Division
2014-11-17 09:19:09 +00:00
Steve Kargl a4e4b355f4 The value small=2**-(p+3), where p is the precision, can be determine from
lgamma(x) = -log(x) - log(1+x) + x*(1-g) + x**2*P(x) with g = 0.57...
being the Euler constant and P(x) a polynomial.  Substitution of small
into the RHS shows that the last 3 terms are negligible in comparison to
the leading term.  The choice of 3 may be conservative.

The value large=2**(p+3) is detemined from Stirling's approximation
lgamma(x) = x*(log(x)-1) - log(x)/2 + log(2*pi)/2 + P(1/x)/x
Again, substitution of large into the RHS reveals the last 3 terms
are negligible in comparison to the leading term.

Move the x=+-0 special case into the |x|<small block.

In the ld80 and ld128 implementaion, use fdlibm compatible comparisons
involving ix, lx, and llx.  This replaces several floating point
comparisons (some involving fabsl()) and also fixes the special cases
x=1 and x=2.

While here
  . Remove unnecessary parentheses.
  . Fix/improve comments due to the above changes.
  . Fix nearby whitespace.

* src/e_lgamma_r.c:
  . Sort declaration.
  . Remove unneeded explicit cast for type conversion.
  . Replace a double literal constant by an integer literal constant.

* src/e_lgammaf_r.c:
  . Sort declaration.

* ld128/e_lgammal_r.c:
  . Replace a long double literal constant by a double literal constant.

* ld80/e_lgammal_r.c:
  . Remove unused '#include float.h'
  . Replace a long double literal constant by a double literal constant.

Requested by:	bde
2014-10-09 22:39:52 +00:00
Steve Kargl 3fbe079a34 Remove whitespace and 2 blank lines. 2014-10-02 23:08:36 +00:00
Steve Kargl dde47d8bbc * Whitespace. 2014-09-25 22:15:10 +00:00
Steve Kargl f382031d34 For targets that have a signed zero, lgamma_r(-0, &signgamp) should
set signgamp = -1.

Submitted by:	enh at google dot com (e_lgamma[f]_r.c)
2014-09-17 19:01:22 +00:00
Steve Kargl f7efd14df1 * Makefile:
. Hook e_lgammal[_r].c to the build.
  . Create man page links for lgammal[-r].3.

* Symbol.map:
  . Sort lgammal to its rightful place.
  . Add FBSD_1.4 section for the new lgamal_r symbol.

* ld128/e_lgammal_r.c:
  . 128-bit implementataion of lgammal_r().

* ld80/e_lgammal_r.c:
  . Intel 80-bit format implementation of lgammal_r().

* src/e_lgamma.c:
  . Expose lgammal as a weak reference to lgamma for platforms
    where long double is mapped to double.

* src/e_lgamma_r.c:
  . Use integer literal constants instead of real literal constants.
    Let compiler(s) do the job of conversion to the appropriate type.
  . Expose lgammal_r as a weak reference to lgamma_r for platforms
    where long double is mapped to double.

* src/e_lgammaf_r.c:
  . Fixed the Cygnus Support conversion of e_lgamma_r.c to float.
    This includes the generation of new polynomial and rational
    approximations with fewer terms.  For each approximation, include
    a comment on an estimate of the accuracy over the relevant domain.
  . Use integer literal constants instead of real literal constants.
    Let compiler(s) do the job of conversion to the appropriate type.
    This allows the removal of several explicit casts of double values
    to float.

* src/e_lgammal.c:
  . Wrapper for lgammal() about lgammal_r().

* src/imprecise.c:
  . Remove the lgamma.

* src/math.h:
  . Add a prototype for lgammal_r().

* man/lgamma.3:
  . Document the new functions.

Reviewed by:	bde
2014-09-15 23:21:57 +00:00
Steve Kargl e85326216f Remove an initialized, but otherwise, unused variable. 2014-09-04 23:50:05 +00:00
Steve Kargl 733331540a According to the ISO C standard, lgamma(-integer) returns
inf and raises the divided-by-zero exception.  Compilers
constant fold one/zero to inf but do not raise the exception.
Introduce a volatile vzero to prevent the constant folding.

Move the declaration of zero into the main declaration block.

While here, fix a nearby disordering of 'lx,ix'

Discussed with:	bde
2014-09-01 18:57:13 +00:00
Steve Kargl e63062b5bf Fix a tab that somehow became 8 spaces.
Remove parentheses in a return statement to be consistent with the
rest of the file.

Rename sin_pi() in the float version to sin_pif().

Remove large comment that precedes sin_pif().  The comment
duplicates a comment in e_lgamma_r.c where the algorithm
is documented.

Requested by:	bde
2014-09-01 16:24:25 +00:00
Steve Kargl 795b92049d Compute sin(pi*x) without actually doing the pi*x multiplication.
sin_pi(x) is only called for x < 0 and |x| < 2**(p-1) where p is
the precision of x.  The new argument reduction is an optimization
compared to the old code, and it removes a chunk of dead code.
Accuracy tests in the intervals (-21,-20), (-20,-19), ... (-1,0)
show no differences between the old and new code.

Obtained from:	bde
2014-08-31 21:38:03 +00:00
Steve Kargl 53c7f22849 Fix the order of "const volatile" to be consistent with
the rest of msun.
2014-08-30 17:31:53 +00:00
Steve Kargl 79c2e69a3f Make tiny volatile to prevent the compiler(s) from
constant folding expressions of the form "1 - tiny",
which are used to raise FE_INEXACT.
2014-08-30 17:14:47 +00:00
Simon J. Gerraty ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Warner Losh 161fedb9cc From https://sourceware.org/ml/newlib/2014/msg00113.html
By Richard Earnshaw at ARM
>
>GCC has for a number of years provides a set of pre-defined macros for
>use with determining the ISA and features of the target during
>pre-processing.  However, the design was always somewhat cumbersome in
>that each new architecture revision created a new define and then
>removed the previous one.  This meant that it was necessary to keep
>updating the support code simply to recognise a new architecture being
>added.
>
>The ACLE specification (ARM C Language Extentions)
>(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.set.swdev/index.html)
>provides a much more suitable interface and GCC has supported this
>since gcc-4.8.
>
>This patch makes use of the ACLE pre-defines to map to the internal
>feature definitions.  To support older versions of GCC a compatibility
>header is provided that maps the traditional pre-defines onto the new
>ACLE ones.

Stop using __FreeBSD_ARCH_armv6__ and switch to __ARM_ARCH >= 6 in the
couple of places in tree. clang already implements ACLE. Add a define
that says we implement version 1.1, even though the implementation
isn't quite complete.
2014-08-14 04:20:13 +00:00
Steve Kargl 55ad7cd740 When r255294 was committed, it exposed the symbols lgammal, powl,
and tgammal in libm.  These functions are part of ISO/IEC 9899:1999
and their prototypes should have been moved into the appropriate
__ISO_C_VISIBLE >= 1999 section.  After moving the prototypes,
remnants of r236148 can be removed.

PR:		standards/191754
Reviewed by:	bde
2014-08-09 15:53:40 +00:00
Steve Kargl d781108453 * Update the comments to agree with commit r226595.
* While here, fix a nearby typo in a comment.
2014-07-13 23:10:39 +00:00
Steve Kargl 3b5e0d0f96 * Makefile:
. Add s_erfl.c to building libm.
  . Add MLINKS for erfl.3 and erfcl.3.

* Symbol.map:
  . Move erfl and erfcl to their proper location.

* ld128/s_erfl.c:
  . Implementations of erfl and erfcl in the IEEE 754 128-bit format.

* ld80/s_erfl.c:
  . Implementations of erfl and erfcl in the Intel 80-bit format.

* man/erf.3:
  . Document the new functions.
  . While here, remove an incomplete sentence.

* src/imprecise.c:
  . Remove the stupidity of mapping erfl and erfcl to erf and erfc.

* src/math.h:
  . Move the declarations of erfl and erfcl to their proper place.

* src/s_erf.c:
  . For architectures where double and long double are the same
    floating point format, use weak references to map erfl to
    erf and ercl to erfc.

Reviewed by:	bde (many earlier versions)
2014-07-13 17:05:03 +00:00
Steve Kargl 7e1c60ae94 * Use 9 digits instead of 11 digits in efx and efx8.
* Update the domain and range of comments for the polynomial
  approximations, including using the the correct variable names
  (e.g., pp(x) instead of p(x)).

* Use hex values of the form 0x3e0375d4 instead of 0x1.06eba8p-3,
  which was obtained from printf("%.6a").

* In the domain [0.84375, 1.25], qa(x) can be reduced from a 4th
  order polynomial to 3rd order.

* In the domain [1.25,1/0.35], sa(x) can be reduced from a 4th
  order polynomial to 3rd order.

* In the domain [1/0.35, 11], the 4th order polynomials rb(x) and
  sb(x) can be reduced to 2nd and 3rd order, respectively.
2014-07-13 16:24:16 +00:00
Steve Kargl c9cb48ff4d * Update the comments that refer to erf[c](nan) and erf[c](+-inf)
to use erf[c]f.
2014-07-13 16:05:33 +00:00
Steve Kargl 019ffb5df8 * Use the volatile qualifier for 'tiny' to prevent compilers
from erronously constant folding expressions of the form
  '1 - tiny'.  This allows erf[f](x) to raise INEXACT.

* Use 0.5, 1, and 2, which are exactly representable in radix-2
  floating point formats.  This reduces diffs between s_erf[fl].c.

* While here, add a comment about efx and efx8.
2014-07-13 15:45:45 +00:00
Steve Kargl f2c0cd942c Whitespace. 2014-07-13 15:15:51 +00:00
Marcel Moolenaar e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 9d2ab4a62d Merge head 2014-04-27 08:13:43 +00:00
Andrew Turner 8b35d5ac4c Only build the vfp/softfp switching code on armv6 as we don't support vfp
on anything earlier than this. This should fix the armeb and arm builds
when using gcc.
2014-03-16 09:40:05 +00:00
Andrew Turner 4f35216187 Build fenv-vfp.c with the softfp float abi. Without this gcc generates an
incorrect assembly file that doesn't allow for vfp instructions.
2014-03-16 09:38:43 +00:00
Andrew Turner bb6c193ec7 On armv6 access both the softfloat and, when available, the vfp to get and
set the floating-point environment.
2014-03-15 21:58:07 +00:00
Dimitry Andric 6202fb7bd3 In lib/msun/ld128/s_expl.c, remove '/*' within block comment, to avoid a
warning.
2014-02-21 21:54:36 +00:00
Dimitry Andric 2882a0d33c For lib/msun, turn off warnings about unknown pragmas, since
lib/msun/src/e_sqrtl.c uses an unsupported STDC FENV_ACCESS pragma.
2014-02-21 18:49:08 +00:00
Andrew Turner a541d15cfe * Mark static inline functions with __fenv_static.
* Correctly shift the mask when masking/unmasking exceptions.
2014-01-25 18:13:43 +00:00
Andrew Turner cd82739201 Use __fenv_static for all static inline functions. 2014-01-25 16:03:08 +00:00
Steve Kargl 1531aa5f6a * msun/man/cosh.3:
* msun/man/sinh.3:
* msun/man/tanh.3:
  . Fix grammar.

* msun/src/e_coshl.c:
* msun/src/e_sinhl.c:
  . Fix comment.

* msun/src/s_tanhl.c:
  . Remove unused variables.
  . Fix location/indentation of comments.
  . Use comparison involving ints instead of long double.
  . Re-order polynomial evaluation on ld128 for |x| < 0.25.
    For now, retain the older order in an "#if 0 ... #else" block.
  . Use int comparison to short-circuit the |x| < 1.5 condition.

Requested by:	bde
2013-12-31 23:59:33 +00:00
Steve Kargl 36af656535 Fix a mismerge of my local doc changes to msun/man/sinh.3. 2013-12-30 17:11:36 +00:00
Steve Kargl a48e1f224c * Makefile:
. Hook coshl, sinhl, and tanhl into libm.
  . Create symbolic links for corresponding manpages.
  . While here remove a nearby extraneous space.

* Symbol.map:
* src/math.h:
  . Move coshl, sinhl, and tanhl to their proper locations.

* man/cosh.3:
* man/sinh.3:
* man/tanh.3:
  . Update the manpages.

* src/e_cosh.c:
* src/e_sinh.c:
* src/s_tanh.c:
  . Add weak reference for LBDL_MANT_DIG==53 targets.

* src/imprecise.c:
  . Remove the coshl, sinhl, and tanhl kludge.

* src/e_coshl.c:
  . ld80 and ld128 implementation of coshl().

* src/e_sinhl.c:
  . ld80 and ld128 implementation of sinhl().

* src/s_tanhl.c:
  . ld80 and ld128 implementation of tanhl().

Obtained from:	bde (mostly), das and kargl
2013-12-30 01:06:21 +00:00
Steve Kargl 5f63fbd67f * ld80/k_expl.h:
* ld128/k_expl.h:
  . Split out a computational kernel,__k_expl(x, &hi, &lo, &k) from expl(x).
    x must be finite and not tiny or huge.  The kernel returns hi and lo
    values for extra precision and an exponent k for a 2**k scale factor.
  . Define additional kernels k_hexpl() and hexpl() that include a 1/2
    scaling and are used by the hyperbolic functions.

* ld80/s_expl.c:
* ld128/s_expl.c:
  . Use the __k_expl() kernel.

Obtained from:	bde
2013-12-30 00:51:25 +00:00
Steve Kargl 30a919dde7 Yet, another attempt to fix the libm breakage due to the
changes in s_roundl.c to use bit twiddling.

Reported by:	ian
2013-11-07 22:46:13 +00:00
Steve Kargl 0e9dcedc67 Fix bulding libm on platforms with LDBL_MANT_DIG == 53.
Reported by:	ian
2013-11-07 21:20:34 +00:00
Steve Kargl db89cf8efb * Use "math.h" instead of <math.h>.
* Use bit twiddling.  This requires inclusion of math_private.h
  and inclusion of float.h in s_roundl.c.  Raise invalid exception.
* Use literal integer constants where possible.  Let the compiler
  do the appropriate conversion.
* In s_roundf.c, use an F suffix on float constants instead of
  promoting float to double and then converting the result back
  to float. In s_roundl.c, use an L suffix.
* In s_roundl.c, use the ENTERI and RETURNI macros.  This requires
  the inclusion of fpmath.h and on __i386__ class hardware ieeefp.h.

Reviewed by:	bde
2013-11-06 23:44:52 +00:00
Andrew Turner c9081a6c9c Update the hard-float version of the fenv functions to use the VFP unit.
Any other floating-point unit is unsupported on ARM.
2013-10-27 10:44:22 +00:00
Simon J. Gerraty 3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Dimitry Andric f5355ab1ba After r255294, building lib/msun's symbol map (using clang as the
preprocessor) gives the following error:

--- Version.map ---
<stdin>:287:4: error: invalid preprocessing directive
        # Implemented as weak aliases for imprecise versions
          ^
1 error generated.

Change the comment to a C-style one, to prevent this error.

Approved by:	re (hrs)
2013-09-12 20:51:48 +00:00
Simon J. Gerraty d466a5b069 Merge head 2013-09-11 18:16:18 +00:00
Andrew Turner 0a10f22a30 On ARM EABI double precision floating point values are stored in the
endian the CPU is in, i.e. little-endian on most ARM cores.

This allows ARMv4 and ARMv5 boards to boot with the ARM EABI.
2013-09-07 14:04:10 +00:00
David Chisnall 4758b87596 Add stub implementations of the missing C++11 math functions.
These are weak and so can be replaced by other versions in applications
that choose to do so, and will give a linker warning when used so that
applications that rely on the extra precision can avoid them.

Note that since the C/C++ specs only guarantee that long double has
precision equal to double, code that actually relies on these functions
having greater precision is unportable at best and broken at worst.
2013-09-06 07:58:23 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Steve Kargl e826e6be2b * Whitespace. 2013-08-28 16:59:55 +00:00
Steve Kargl 2a3910b931 * s_erf.c:
. Use integer literal constants instead of double literal constants.

* s_erff.c:
  . Use integer literal constants instead of casting double literal
    constants to float.
  . Update the threshold values from those carried over from erf() to
    values appropriate for float.
  . New sets of polynomial coefficients for the rational approximations.
    These coefficients have little, but positive, effect on the maximum
    error in ULP in the four intervals, but do improve the overall
    speed of execution.
  . Remove redundant GET_FLOAT_WORD(ix,x) as hx already contained the
    contents that is packed into ix.
  . Update the mask that is used to zero-out lower-order bits in x in
    the intervals [1.25, 2.857143] and [2.857143, 12].  In tests on
    amd64, this change improves the maximum error in ULP from 6.27739
    and 63.8095 to 3.16774 and 2.92095 on these intervals for erffc().

Reviewed by:	bde
2013-08-27 19:46:56 +00:00
David Chisnall fb69d6083d Restore the longer form of the _Generic. The short form does not work in C++. 2013-07-29 12:33:03 +00:00
David Chisnall 6b69e627a8 Reenable the isnan(double) / isinf(double) declarations when targeting C89 + SUSv2 mode. 2013-07-29 08:32:13 +00:00
David Chisnall b8f19c9247 Cleaner support for type qualifiers.
Submitted by:	Pasi Parviainen
2013-07-13 13:04:38 +00:00
David Chisnall e21be487d3 Ensure that the _Generic() macro in math.h works with qualified types.
tgmath.h contains the same bugs and so should be fixed in the same way.
2013-07-13 10:10:45 +00:00
David Chisnall 1583bcb4ee Fix the build with C++ where __builtin_types_compatible_p is not allowed. 2013-07-12 11:03:51 +00:00
David Chisnall 95f82796a9 Fix some typoes in math.h cleanup. 2013-07-11 19:34:16 +00:00
David Chisnall a3fc79de87 Cleanups to math.h that prevent namespace conflicts with C++.
Reviewed by:	bde
MFC after:	3 days
2013-07-11 17:41:04 +00:00
Eitan Adler 19eb5fb06b Make the order of operations for lib/msun more clear.
Tested with md5 sum of object code

Reported by:	swildner@DragonFlyBSD.org
Submitted by:	bde
2013-06-24 19:12:17 +00:00
David Schultz 998b640bcb Add implementations of acoshl(), asinhl(), and atanhl(). This is a
merge of the work done by bde and myself.
2013-06-10 06:04:58 +00:00
David Schultz 0b8d0b5be9 Style fixes.
Submitted by:	bde
2013-06-05 05:33:01 +00:00
David Schultz c13c6c32b1 Add man links for expl(3) and expm1l(3). 2013-06-04 05:41:38 +00:00
Steve Kargl 1a287d1ddf Change a comma to a semicolon.
Remove a blank line that crept into the declarations.

Fix a comment to show a sign on a NaN.
2013-06-03 20:09:22 +00:00
Steve Kargl 3ffff4bad5 ld80 and ld128 implementations of expm1l(). This code started life
as a fairly faithful implementation of the algorithm found in

PTP Tang, "Table-driven implementation of the Expm1 function
in IEEE floating-point arithmetic," ACM Trans. Math. Soft., 18,
211-222 (1992).

Over the last 18-24 months, the code has under gone significant
optimization and testing.

Reviewed by:	bde
Obtained from:	bde (most of the optimizations)
2013-06-03 19:51:32 +00:00
Steve Kargl 42e4111cab Fix two comments that got lost in the disentanglement of the larger diff. 2013-06-03 19:29:03 +00:00
Steve Kargl 8cc74771f2 ld80/s_expl.c:
* Use integral numerical constants, and let the compiler do the
  conversion to long double.

ld128/s_expl.c:

* Use integral numerical constants, and let the compiler do the
  conversion to long double.
* Use the ENTERI/RETURNI macros, which are no-ops on ld128.  This
  however makes the ld80 and ld128 identical.

Reviewed by:	bde (as part of larger diff)
2013-06-03 19:13:44 +00:00
Steve Kargl 35cbca6a7f Micro-optimization: move the unary mius operator to operate
on a literal constant.

Obtained from:	bde
2013-06-03 18:57:35 +00:00
Steve Kargl a3f70b4ed8 Add a comment to note that bde supplied most, if not all,
of the optimizations.
2013-06-03 18:53:40 +00:00
Steve Kargl 1783063f18 ld80/s_expl.c:
* In the special case x = -Inf or -NaN, use a micro-optimization
  to eliminate the need to access u.xbits.man.

* Fix an off-by-one for small arguments |x| < 0x1p-65.

ld128/s_expl.c:

* In the special case x = -Inf or -NaN, use a micro-optimization
  to eliminate the need to access u.xbits.manh and u.xbits.manl.

* Fix an off-by-one for small arguments |x| < 0x1p-114.

Obtained from:	bde
2013-06-03 18:51:34 +00:00
Steve Kargl 31407861b8 ld80/s_expl.c:
* Update the evaluation of the polynomial.  This allows the removal
  of the now unused variables t23 and t45.

ld128/s_expl.c:

* Update the evaluation of the polynomial and the intermediate
  result t.  This update allows several numerical constants to be
  written as double rather than long double constants.   Update
  the constants as appropriate.

Obtained from:	bde
2013-06-03 18:40:00 +00:00
Steve Kargl 199b8e343d Rename a few P2, P3, ... coefficients to A2, A3, ... missed in
my previous commit.
2013-06-03 18:18:08 +00:00
Steve Kargl f3049ab5f3 Update a comment to reflect that we are using an endpoint of
an interval instead of a midpoint.
2013-06-03 18:14:18 +00:00
Steve Kargl ad36b00fcb Add a u suffix to the IEEEl2bits unions o_threshold and u_threshold,
and use macros to access the e component of the unions.  This allows
the portions of the code in ld80 to be identical to the ld128 code.

Obtained from:	bde
2013-06-03 18:07:04 +00:00
Steve Kargl 4aa8c9453f Introduce the macro LOG2_INTERVAL, which is log2(number of intervals).
Use the macroi as a micro-optimization to convert a subtraction and
division to a shift.

Obtained from:	bde
2013-06-03 17:51:08 +00:00
Steve Kargl 03e1315345 Whitespace. 2013-06-03 17:40:52 +00:00
Steve Kargl bb23de67bb * Rename the polynomial coefficients from P2, P3, ... to A2, A3, ....
The names now coincide with the name used in PTP Tang's paper.

* Rename the variable from s to tbl to better reflect that
  this is a table, and to be consistent with the naming scheme
  in s_exp2l.c

Reviewed by:	bde (as part of larger diff)
2013-06-03 17:36:26 +00:00
Steve Kargl b419a5506a * Style(9). Start non-Copyright fancy formatted comments with /**.
Reviewed by:	bde (as part of larger diff)
2013-06-03 17:24:46 +00:00
Steve Kargl a1d69112c1 ld80/s_expl.c:
* Update Copyright years to include 2013.

ld128/s_expl.c:

* Correct and update Copyright years.  This code originated from
  the ld80 version, so it should reflect the same time period.

Reviewed by:	bde (as part of larger diff)
2013-06-03 17:21:43 +00:00
David Schultz 25a4d6bfda Add logl, log2l, log10l, and log1pl.
Submitted by:	bde
2013-06-03 09:14:31 +00:00
David Schultz e4afa19c33 I'm happy to finally commit stephen@'s implementations of cacos,
cacosh, casin, casinh, catan, and catanh. Thanks to stephen@ and bde@
for working on these.

Submitted by:	stephen@
Reviewed by:	bde
2013-05-30 04:49:26 +00:00
Steve Kargl ad600fe1aa Style(9)
Approved by:	das (implicit)
Reported by:	jh
2013-05-27 22:45:05 +00:00
Steve Kargl 532fd61b45 * Update polynomial coefficients.
* Use ENTERI/RETURNI to allow the use of FP_PE on i386 target.

Reviewed by:	das (and bde a long time ago)
Approved by:	das (mentor)
Obtained from:	bde (polynomial coefficients)
2013-05-27 20:43:16 +00:00
David Schultz 7dbbb6dde3 Fix some regressions caused by the switch from gcc to clang. The fixes
are workarounds for various symptoms of the problem described in clang
bugs 3929, 8100, 8241, 10409, and 12958.

The regression tests did their job: they failed, someone brought it
up on the mailing lists, and then the issue got ignored for 6 months.
Oops. There may still be some regressions for functions we don't have
test coverage for yet.
2013-05-27 08:50:10 +00:00
Konstantin Belousov 826549e53d Merge the 386 and amd64 versions of the fenv.h, to make cc -m32
compilations which use fenv.h work.

Reviewed by:	tjil
Sponsored by:	The FreeBSD Foundation
2013-04-21 13:31:55 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Dimitry Andric 0779690c2e Only define isnan, isnanf, __isnan and __isnanf in libc.so, not in
libc.a and libc_p.a.  In addition, define isnan in libm.a and libm_p.a,
but not in libm.so.

This makes it possible to statically link executables using both isnan
and isnanf with libc and libm.

Tested by:	kargl
MFC after:	1 week
2012-11-10 21:22:10 +00:00
Kevin Lo 0f5e7edc14 Fix typo; s/ouput/output 2012-11-07 07:00:59 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Warner Losh 98fd12e162 Revert r241756 2012-10-22 13:21:11 +00:00
Warner Losh b3f94d242f Revert r241755 2012-10-22 13:20:31 +00:00
Warner Losh 527a7c56f7 Document the method used to compute expf. Taken from exp, with
changes to reflect differences in computation between the two.
2012-10-19 22:47:44 +00:00
Warner Losh aa616aa22d Document the methods used to compute logf. Taken and edited from the
double version, with adaptations for the differences between it and
the float version.
2012-10-19 22:46:48 +00:00
Joel Dahl 284eab32c0 mdoc: avoid nested displays. 2012-10-14 14:45:54 +00:00
Steve Kargl f81d134e7e * Update the comment that explains the choice of values in the
table and the requirement on trailing zero bits.

* Remove the __aligned() compiler directives as these were found
  to have a negative effect on the produced code.

Submitted by:	bde
Approved by:	das (mentor)
2012-10-13 19:53:11 +00:00
Steve Kargl a077586c53 * src/math_private.h:
. Change the API for the LD80C by removing the explicit passing
    of the sign bit.  The sign can be determined from the last
    parameter of the macro.
  . On i386, load long double by bit manipulations to work around
    at least a gcc compiler issue.  On non-i386 ld80 architectures,
    use a simple assignment.

* ld80/s_expl.c:
  . Update the only consumer of LD80C.

Submitted by:	bde
Approved by:	das (mentor)
2012-09-29 16:40:12 +00:00
Steve Kargl dba466c344 * ld80/s_expl.c:
. Fix the threshold for expl(x) where |x| is small.
  . Also update the previously incorrect comment to match the
    new threshold.

* ld128/s_expl.c:
  . Re-order logic in exceptional cases to match the logic used in
    other long double functions.
  . Fix the threshold for expl(x) where is |x| is small.
  . Also update the previously incorrect comment to match the
    new threshold.

Submitted by:	bde
Approved by:	das (mentor)
2012-09-23 18:32:03 +00:00
Steve Kargl 724c1ee29f Fix whitespace issue.
Approved by:	das (mentor, implicit)
2012-09-23 18:13:46 +00:00
Steve Kargl 8f647ffd7f * ld80/s_expl.c:
. Guard a comment from reformatting by indent(1).
  . Re-order variables in declarations to alphabetical order.
  . Remove a banal comment.

* ld128/s_expl.c:
  . Add a comment to point to ld80/s_expl.c for implementation details.
  . Move the #define of INTERVAL to reduce the diff with ld80/s_expl.c.
  . twom10000 does not need to be volatile, so move its declaration.
  . Re-order variables in declarations to alphabetical order.
  . Add a comment that describes the argument reduction.
  . Remove the same banal comment found in ld80/s_expl.c.

Reviewed by:	bde
Approved by:	das (mentor)
2012-09-23 18:06:27 +00:00
Steve Kargl c1a077829a * Update the lookup table to use 53-bit high and low values.
Also, update the comment to describe the choice of using
  a high and low decomposition of 2^(i/INTERNVAL) for
  0 <= i <= INTERVAL in preparation for an implementation of
  expm1l.

* Move the #define of INTERVAL above the comment, because the
  comment refers to INTERVAL.

Reviewed by:	bde
Approved by:	das (mentor)
2012-09-23 17:36:01 +00:00
Steve Kargl 340076f0f6 * Use ENTERI() and RETURNI() to toggle the rounding precision if
necessary, so that cosl(), sinl() and tanl() work on i386 even
  for naive callers.

Suggested by:	bde
Reviewed by:	bde
Approved by: 	das (mentor)
2012-09-22 15:38:29 +00:00
Steve Kargl e6f9129aa0 * Make STRICT_ALIGN() work for doubles as well as for floats. This
only affects i386.  The double case was intentionally left broken
  as an optimization, but we are getting closer to supporting
  applications and/or kernels that change the (FreeBSD i386) default
  rounding precision from FP_PD to FP_PE and never change it back,
  and this requires the STRICT_ALIGN()s that were added to support
  FP_PE to actually work in all precisions.

* Remove an extraneous semicolon at the end of a macro that was
  supposed to be function-like.

Submitted by:	bde
Approved by:	das (mentor)
2012-09-22 15:19:11 +00:00
Tijl Coosemans 71dad5d6ad Optimise i387 trigonometric functions. Replace "andw 0x400,%ax \ jnz" with
"sahf \ jp", "fprem1" with "fprem" and "fstsw %ax" with "fnstsw %ax".
2012-09-16 16:58:49 +00:00
Joel Dahl ff34c32ac4 Minor mdoc fix. 2012-09-11 17:40:06 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Dimitry Andric f049a6cb4a Add __always_inline to __ieee754_rem_pio2() and __ieee754_rem_pio2f(),
since some older versions of gcc refuse to inline these otherwise.

Requested by:	bde
MFC after:	1 week
2012-08-11 15:47:22 +00:00
Dimitry Andric 2b795b2921 Change a few extern inline functions in libm to static inline, since
they need to refer to static constants, which C99 does not allow for
extern inline functions.

While here, change a comment in e_rem_pio2f.c to mention the correct
number of bits.

Reviewed by:	bde
MFC after:	1 week
2012-08-11 11:13:48 +00:00
Steve Kargl 82b89f4850 ieeefp.h is only needed on i386 class hardware.
Submitted by:	bde
Approved by:	das (pre-approved)
2012-07-30 21:58:28 +00:00
Steve Kargl ca50c4b871 Whitespace.
Submitted by:	bde
Approved by:	das (pre-approved)
2012-07-30 21:55:49 +00:00
Steve Kargl 8345cbd275 Replace the macro name NUM with INTERVALS. This change provides
compatibility with the INTERVALS macro used in the soon-to-be-commmitted
expm1l() and someday-to-be-committed log*l() functions.

Add a comment into ld128/s_expl.c noting at gcc issue that was
deleted when rewriting ld80/e_expl.c as ld128/s_expl.c.

Requested by:	bde
Approved by:	das (mentor)
2012-07-26 04:05:08 +00:00
Steve Kargl f7cfe68f59 * ld80/expl.c:
. Remove a few #ifdefs that should have been removed in the initial
    commit.
  . Sort fpmath.h to its rightful place.

* ld128/s_expl.c:
  . Replace EXPMASK with its actual value.
  . Sort fpmath.h to its rightful place.

Requested by:	bde
Approved by:	das (mentor)
2012-07-26 03:59:33 +00:00
Steve Kargl 3458a81e65 Replace code that toggles between 53 and 64 bits on i386
class hardware with the ENTERI and RETURNI macros, which
are now available in math_private.h.

Suggested by:	bde
Approved by: das (mentor)
2012-07-26 03:50:24 +00:00
Steve Kargl 8a489dc248 Hook ld80/s_expl.c or ld128/s_expl.c into the building of libm.
PR: standards/152415
Approved by: das (mentor)
2012-07-23 19:23:49 +00:00
Steve Kargl b83ccea32c Compute the exponential of x for Intel 80-bit format and IEEE 128-bit
format.  These implementations are based on

PTP Tang, "Table-driven implementation of the exponential function
in IEEE floating-point arithmetic," ACM Trans. Math. Soft., 15,
144-157 (1989).

PR: standards/152415
Submitted by: kargl
Reviewed by: bde, das
Approved by: das (mentor)
2012-07-23 19:13:55 +00:00
David Chisnall 8f62d384b9 Allow inclusion of libc++ <cmath> to work after including math.h
Submitted by:	Yamaya Takashi
Reviewed by:	das
MFC after:	1 week
2012-05-27 12:54:41 +00:00
Glen Barber a3fb6da9ba General mdoc(7) and typo fixes.
PR:		167734
Submitted by:	Nobuyuki Koganemaru (kogane!jp.freebsd.org)
MFC after:	3 days
2012-05-11 20:06:46 +00:00
Dag-Erling Smørgrav 084f679591 I stopped using my middle name years ago. 2012-04-25 18:07:35 +00:00
Joel Dahl 748611c9c0 mdoc: fix column names, indentation, column separation within each row, and
quotation. Also make sure we have the same amount of columns in each row as
the number of columns we specify in the head arguments.

Reviewed by:	brueffer
2012-04-07 09:05:30 +00:00
David Schultz 1cbd288942 Fix a bug in remquo{,f,l}, in which the quotient didn't always have the
correct sign when the remainder was 0.

Fix a separate bug in remquo alone, in which the remainder and
quotient were both off by a bit in certain cases involving subnormal
remainders.

The bugs affected all platforms except amd64 and i386, on which the
routines are implemented in assembly.

PR:		166463
Submitted by:	Ilya Burylov
MFC after:	2 weeks
2012-04-07 03:59:12 +00:00
Joel Dahl 41949a1ed5 Remove superfluous paragraph macro. 2012-03-25 12:13:24 +00:00
David Schultz 6e3ab4e1b3 Fix a small nit noted by bde: exp_x should be of type float, not double. 2012-01-20 07:02:42 +00:00
David Schultz b7e83566eb Add a change I missed in r230367 (don't inline arm's fenv.h functions). 2012-01-20 07:01:58 +00:00
David Schultz 7082a2cf72 Don't inline fenv.h functions on arm for now. Inlining makes sense:
the function bodies require only 2 to 10 instructions.  However, it
leads to application binaries that refer to a private ABI, namely, the
softfloat innards in libc.  This could complicate future changes in
the implementation of the floating-point emulation layer, so it seems
best to have programs refer to the official fe* entry points in libm.
2012-01-20 06:54:30 +00:00
David Schultz 7bde21b1f9 Add an implementation of fenv.h intended for platforms that lack an FPU and
use softfloat.

Thanks to Ian Lepore for testing and debugging this patch.  The fenv
regression tests pass (at least for Ian's arm chip) with this change.
2012-01-16 04:09:17 +00:00
Ulrich Spörlein bf3f9db657 Convert files to UTF-8 and add some copyright markers where missing. 2012-01-07 16:13:56 +00:00
David Chisnall e481b86384 Expose the unimplemented libm functions in the math.h header. This allows C++'s <cmath> to work without the compiler complaining that the C++ versions are calling implicitly-declared functions. You will still get a linker error when they are called. OpenBSD 5.0 claims to fully implement the C99 <math.h> stuff, so might be worth investigating...
Reviewed by:	das
Approved by:	dim (mentor)
2011-11-12 19:55:48 +00:00
David Schultz 1f52bcdde4 Minor corrections and clarifications regarding exceptions. 2011-10-21 14:23:59 +00:00
David Schultz 0c7e4d5fc1 Fix a regression introduced in r226371: When the high part of x*y
exactly cancels with z, return the low part of x*y instead of
discarding it.
2011-10-21 06:30:43 +00:00
David Schultz bc23acdc32 Fix a corner case: tan(large + Inf i) == NaN + NaN i. 2011-10-21 06:30:16 +00:00
David Schultz c6df46bafb Improved handling of large x in ccosh{,f}():
- Handle cases where exp(x) would overflow, but ccosh(x) ~= exp(x) / 2
  shouldn't.
- Use the ccosh(x) ~= exp(x) / 2 approximation to simplify the calculation
  when x is large.

Similarly for csinh().  Also fixed the return value of csinh(-Inf +- 0i).
2011-10-21 06:29:32 +00:00
David Schultz d4657ac799 Use __ldexp_exp() to simplify things and improve accuracy for x near
the overflow threshold.
2011-10-21 06:28:47 +00:00
David Schultz 12188b77a2 The cexp() and {,c}{cos,sin}h functions all need to be able to compute
exp(x) scaled down by some factor, and the challenge is doing this
accurately when exp(x) would overflow.  This change replaces all of
the tricks we've been using with common __ldexp_exp() and
__ldexp_cexp() routines that handle all the scaling.

bde plans to improve on this further by moving the guts of exp() into
k_exp.c and handling the scaling in a more direct manner.  But the
current approach is simple and adequate for now.
2011-10-21 06:27:56 +00:00
David Schultz f2ea2b9d27 Use STRICT_ASSIGN() to ensure that the compiler doesn't screw things
up by storing x in a wider type than it's supposed to.

Submitted by:	bde
2011-10-21 06:26:38 +00:00
David Schultz cd24d79843 Per IEEE754r, pow(1, y) is 1 even if y is NaN, and pow(-1, +-Inf) is 1.
MFC after:	2 weeks
2011-10-21 06:26:07 +00:00
David Schultz 741ae1d017 Bugfix: feenableexcept() and fedisableexcept() should just return the
old exception mask, not mask | ~FE_ALL_EXCEPT.

MFC after:	2 weeks
2011-10-21 06:25:31 +00:00
David Schultz 715a43edd0 It's no longer accurate to say that math.h "constitute[s] the C math
library," since complex.h, tgmath.h, and fenv.h are also part of the
math library.  Replace the outdated sentence with some references to
the other parts.
2011-10-17 06:10:32 +00:00
David Schultz 3daee1d6c3 Add c{cos,sin,tan}{,h}{,f} functions. This is joint work with
bde and kargl.
2011-10-17 05:41:03 +00:00
Eitan Adler 36daf0495a - change "is is" to "is" or "it is"
- change "the the" to "the"

Approved by:	lstewart
Approved by:	sahil (mentor)
MFC after:	3 days
2011-10-16 14:30:28 +00:00
David Schultz 5d9fefacf2 Use #include "fenv.h" instead of #include <fenv.h>. This makes it
more convenient to compile the math library by itself.

Requested by:	bde
2011-10-16 05:37:56 +00:00
David Schultz 0ddbe81e4f Fix some non-standard variable declarations. 2011-10-16 05:37:20 +00:00
David Schultz 4ce31585dc Optimize the case of pure imaginary arguments. Calls like this are
common, e.g., in DFT implementations.

Discussed with:	bde, kargl
2011-10-16 05:37:01 +00:00
David Schultz e62394861d Move the macros GET_LDBL_EXPSIGN() and SET_LDBL_EXPSIGN() into
math_private.h, so they can be used elsewhere in the math library.
2011-10-16 05:36:39 +00:00
David Schultz eccf8b3a30 Remove an unused variable. 2011-10-16 05:36:23 +00:00
David Schultz e595c01fd8 Remove some unnecessary initializations.
Obtained from:	DragonFlyBSD
2011-10-15 07:00:28 +00:00
David Schultz b052ec9065 Various changes to improve the accuracy and speed of log{2,10}{,f}.
- Rename __kernel_log() to k_log1p().
- Move some of the work that was previously done in the kernel log into
  the callers.  This enables further refactoring to improve accuracy or
  speed, although I don't recall the details.
- Use extra precision when adding the final scaling term, which improves
  accuracy.
- Describe and work around compiler problems that break some of the
  multiprecision calculations.

A fix for a small bug is also included:
- Add a special case for log*(1).  This is needed to ensure that log*(1) == +0
  instead of -0, even when the rounding mode is FE_DOWNWARD.

Submitted by:	bde
2011-10-15 05:23:28 +00:00
David Schultz 5ebf26f6a1 Style fixes and updates to comments.
Submitted by:	bde
2011-10-15 05:00:56 +00:00
David Schultz 15d5d9deb1 Don't define FP_FAST_FMA on sparc64; with the recent fixes, fma() is
no longer "fast" on sparc64.  (It really wasn't to begin with, since
the old implementation was using long doubles, and long doubles are
emulated in software on sparc64.)
2011-10-15 04:24:54 +00:00
David Schultz 3d4dfde48a Add INSERT_WORD64 and EXTRACT_WORD64 macros for use in s_fma.c. 2011-10-15 04:22:55 +00:00
David Schultz 90a83ac60a Replace two lines accidentally removed in r226218. Thanks to bde
for noticing this.
2011-10-15 04:17:20 +00:00
David Schultz ec95083025 Fix a double-rounding bug in fma{,f,l}. The bug would occur in
round-to-nearest mode when the result, rounded to twice machine
precision, was exactly halfway between two machine-precision
values.  The essence of the fix is to simulate a "sticky bit" in
the pathological cases, which is how hardware implementations
break the ties.

MFC after:	1 month
2011-10-15 04:16:58 +00:00
David Schultz 7792754061 Refactor this code by introducing separate functions to handle the
extra-precision add and multiply operations. This simplifies future
work but shouldn't result in any functional change.
2011-10-11 05:17:45 +00:00