summaryrefslogtreecommitdiffstats
path: root/lib/msun/src
Commit message (Collapse)AuthorAgeFilesLines
* Synchronize most of libm with head as of r323004. This excludes a fewdim2018-02-2422-28/+1023
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arch-specific updates for powerpcspe, mips and riscv, for which support has not been merged yet. Bump __FreeBSD_version for the addition of cacoshl, cacosl, casinhl, casinl, catanl, catanhl, sincos, sincosf, and sincosl. MFC r305382 (by bde): 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. MFC r305384 (by bde): 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. MFC r305385 (by bde): Oops, the previous i386 version of e_fmodf.S and e_fmodl.S was actually the amd64 version. MFC r306409 (by emaste): 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 MFC r306410 (by emaste): libm: simplify i387 subdir logic with make's :S substitution MFC r306527 (by emaste): libm: remove unused variables for LDBL_MANT_DIG != 113 Sponsored by: The FreeBSD Foundation MFC r306709 (by emaste): libm: remove unused variables Sponsored by: The FreeBSD Foundation MFC r307066 (by br): 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 MFC r308172 (by emaste): 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 MFC r313761 (by mmokhi): Add casinl() cacosl() catanl() casinhl() cacoshl() catanhl() APIs to msun to improve C11 conformance. PR: 216850 216851 216852 216856 216857 216858 Submitted by: mmokhi Reported by: sgk@troutmask.apl.washington.edu Reviewed by: bde, mat, theraven Approved by: bde (src committer), mat (mentor) Differential Revision: https://reviews.freebsd.org/D9491 MFC r313863 (by mmokhi): Fix building of r313761 on platforms that `long double` is alias of `double` (MIPS, etc) PR: 216850 216851 216852 216856 216857 216858 Reported by: emsate Reviewed by: bde emaste hselasky Approved by: bde emaste hselasky Differential Revision: https://reviews.freebsd.org/D9491 MFC r313864 (by mmokhi): Add documentations related to new APIs of r313761 PR: 216850 216851 216852 216856 216857 216858 Submitted by: sgk@troutmask.apl.washington.edu Reported by: sgk@troutmask.apl.washington.edu Reviewed by: bde emaste hselasky Approved by: bde emaste hselasky Differential Revision: https://reviews.freebsd.org/D9491 MFC r314950 (by ngie): Don't expect :test_large_inputs to fail with i386 anymore Recent changes (maybe a side-effect of the ATF-ification in r314649) invalidate the failure expectation. PR: 205446 Sponsored by: Dell EMC Isilon MFC r317349 (by pfg): msun: Remove trailing space in Sunsoft copyright statement. Submittedby: kargl MFC r319047 (by mmel): Implement sincos, sincosf, and sincosl. The primary benefit of these functions is that argument reduction is done once instead of twice in independent calls to sin() and cos(). * lib/msun/Makefile: . Add s_sincos[fl].c to the build. . Add sincos.3 documentation. . Add appropriate MLINKS. * lib/msun/Symbol.map: . Expose sincos[fl] symbols in dynamic libm.so. * lib/msun/man/sincos.3: . Documentation for sincos[fl]. * lib/msun/src/k_sincos.h: . Kernel for sincos() function. This merges the individual kernels for sin() and cos(). The merger offered an opportunity to re-arrange the individual kernels for better performance. * lib/msun/src/k_sincosf.h: . Kernel for sincosf() function. This merges the individual kernels for sinf() and cosf(). The merger offered an opportunity to re-arrange the individual kernels for better performance. * lib/msun/src/k_sincosl.h: . Kernel for sincosl() function. This merges the individual kernels for sinl() and cosl(). The merger offered an opportunity to re-arrange the individual kernels for better performance. * lib/msun/src/math.h: . Add prototytpes for sincos[fl](). * lib/msun/src/math_private.h: . Add RETURNV macros. This is needed to reset fpsetprec on I386 hardware for a function with type void. * lib/msun/src/s_sincos.c: . Implementation of sincos() where sin() and cos() were merged into one routine and possibly re-arranged for better performance. * lib/msun/src/s_sincosf.c: . Implementation of sincosf() where sinf() and cosf() were merged into one routine and possibly re-arranged for better performance. * lib/msun/src/s_sincosl.c: . Implementation of sincosl() where sinl() and cosl() were merged into one routine and possibly re-arranged for better performance. PR: 215977, 218300 Submitted by: Steven G. Kargl <sgk@troutmask.apl.washington.edu> Differential Revision: https://reviews.freebsd.org/D10765 MFC r321457 (by ngie): Mark :reduction as an expected failure It fails with clang 5.0+. PR: 220989 Reported by: Jenkins MFC r322418 (by rlibby): lib/msun: avoid referring to broken LDBL_MAX LDBL_MAX is broken on i386: https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000288.html Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32 for some time, and newer versions of gcc are now warning that the "floating constant exceeds range of 'long double'". Avoid this by referring to half the value of LDBL_MAX instead. Reviewed by: bde Approved by: markj (mentor) Sponsored by: Dell EMC Isilon MFC r322435 (by rlibby): Revert r322418, LDBL_MAX_EXP unsuitable for macro pasting on some arches Either need a different way to spell HALF_LDBL_MAX, or a different way to spell LDBL_MAX_EXP, or a different approach. Reported by: ian MFC r322921 (by ngie): Revert r321457 It doesn't fail after ^/head@r322855 (the releng_50 clang merge). PR: 220989 (cherry picked from commit 68896d08c13fabea18690d4c5369de8a5e24ba82)
* MFC r318259:dim2017-05-162-2/+2
| | | | | | | | | Silence a -Wunused warning about the junk variable being used to raise an inexact floating point exception. The variable cannot be eliminated, unfortunately, otherwise the desired addition triggering the exception will be emitted neither by clang, nor by gcc. Reviewed by: Steve Kargl, bde
* MFC r305380:bde2016-09-191-0/+6
| | | | | | Fix missing fmodl() on arches with 53-bit long doubles. PR: 199422, 211965
* Fix frexpl() declaration to not include the field name.trasz2016-06-091-1/+1
| | | | MFC after: 1 month
* lib: minor spelling fixes in comments.pfg2016-05-012-2/+2
| | | | No functional change.
* In libm's exp2(3), avoid left-shifting a negative integer, which isdim2015-08-091-2/+2
| | | | | | | undefined. Replace it with the intended value, in a defined way. Reviewed by: bde MFC after: 3 days
* Follow up to r284427: fix NaN mixing for ctanhf too.tijl2015-06-151-1/+2
|
* - Change comments to be more consistent with s_ccosh.c and s_csinh.c.tijl2015-06-152-20/+21
| | | | | | | | - 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
* Fix some exceptional cases where the sign of the result is unspecifiedtijl2015-06-152-47/+43
| | | | | | | 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
* Fix some exceptional cases where the sign of the result is unspecifiedtijl2015-06-152-34/+32
| | | | | | | but must still satisfy ccosh(conj(z)) == conj(ccosh(z)) and ccosh(-z) == ccosh(z). In collaboration with: bde
* In r279493, the functions pzero[f](), qzero[f], pone[f](),kargl2015-05-174-4/+4
| | | | | | | | 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
* According to POSIX.1-2008, the Bessel functions of second kindkargl2015-03-106-22/+57
| | | | | | | | | 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)
* Give compilers a stronger hint to inline the functionskargl2015-03-014-8/+16
| | | | | pzero[f], qzero[f], pone[f], and qone[f]. While here fix the function declarations in accordance with style(9).
* When j0() and j1() were converted to j0f() and j1f(), the thresholdkargl2015-03-012-16/+16
| | | | | | | | | | 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
* msun: drop unnecessary checks (part 2).pfg2015-02-244-4/+4
| | | | | | Drop an unnecessary check in some calculations. The check would have Coverity falsely conclude that a variable could be left undefined.
* msun: drop unnecessary checks.pfg2015-02-224-4/+4
| | | | | | | | | 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
* Truncate the exponent 'n' of type long to a domain containedkargl2015-02-071-19/+9
| | | | | | | | | | 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
* scanblnl: drop extra braces.pfg2015-02-031-2/+1
| | | | Pointed out by: bde
* Reduce confusion in scalbnl() family of functions.pfg2015-02-031-3/+10
| | | | | | | | | | | 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
* msun: use previously ignored value.pfg2015-01-301-22/+4
| | | | | | | | 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
* Clarify to explain that C99 conforming compilers don't need CMPLX*().ed2014-12-241-3/+2
| | | | Discussed with: kargl@
* Rename cpack*() to CMPLX*().ed2014-12-1622-180/+193
| | | | | | | | | | | | | | | 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.
* Adjust the |x| small limit from 0x1p-7 to 0x1p-9. Thiskargl2014-12-081-1/+1
| | | | | | | adjustment increases the number of correctly rounded cases within the interval on i386. Requested by: bde
* Update the constants associated with the evaluation of j0f(x)kargl2014-12-052-4/+4
| | | | | | | | | | 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
* Fix a 20+ year bug by using an appropriate constant forkargl2014-12-041-2/+2
| | | | | | | the transition from one asymptotic approximation to another for the zeroth order Bessel and Neumann functions. Reviewed by: bde
* Revert r274772: it is not valid on MIPSemaste2014-11-251-2/+2
| | | | Reported by: sbruno
* Use canonical __PIC__ flagemaste2014-11-211-2/+2
| | | | | | | | 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
* The value small=2**-(p+3), where p is the precision, can be determine fromkargl2014-10-092-44/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove whitespace and 2 blank lines.kargl2014-10-021-14/+12
|
* * Whitespace.kargl2014-09-251-3/+1
|
* For targets that have a signed zero, lgamma_r(-0, &signgamp) shouldkargl2014-09-172-2/+10
| | | | | | set signgamp = -1. Submitted by: enh at google dot com (e_lgamma[f]_r.c)
* * Makefile:kargl2014-09-156-100/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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
* Remove an initialized, but otherwise, unused variable.kargl2014-09-042-2/+0
|
* According to the ISO C standard, lgamma(-integer) returnskargl2014-09-012-11/+13
| | | | | | | | | | | | 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
* Fix a tab that somehow became 8 spaces.kargl2014-09-012-10/+5
| | | | | | | | | | | | | 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
* Compute sin(pi*x) without actually doing the pi*x multiplication.kargl2014-08-312-53/+49
| | | | | | | | | | 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
* Fix the order of "const volatile" to be consistent withkargl2014-08-302-2/+2
| | | | the rest of msun.
* Make tiny volatile to prevent the compiler(s) fromkargl2014-08-302-2/+5
| | | | | constant folding expressions of the form "1 - tiny", which are used to raise FE_INEXACT.
* When r255294 was committed, it exposed the symbols lgammal, powl,kargl2014-08-091-22/+3
| | | | | | | | | | 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
* * Update the comments to agree with commit r226595.kargl2014-07-131-4/+4
| | | | * While here, fix a nearby typo in a comment.
* * Makefile:kargl2014-07-133-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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)
* * Use 9 digits instead of 11 digits in efx and efx8.kargl2014-07-131-54/+49
| | | | | | | | | | | | | | | | | | * 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.
* * Update the comments that refer to erf[c](nan) and erf[c](+-inf)kargl2014-07-131-4/+4
| | | | to use erf[c]f.
* * Use the volatile qualifier for 'tiny' to prevent compilerskargl2014-07-132-10/+21
| | | | | | | | | | 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.
* Whitespace.kargl2014-07-131-25/+18
|
* Remove ia64.marcel2014-07-071-4/+0
| | | | | | | | | | | | | | | | | 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
* Use __fenv_static for all static inline functions.andrew2014-01-251-3/+3
|
* * msun/man/cosh.3:kargl2013-12-313-7/+15
| | | | | | | | | | | | | | | | | | | | * 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
* * Makefile:kargl2013-12-308-6/+446
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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
* Yet, another attempt to fix the libm breakage due to thekargl2013-11-071-0/+2
| | | | | | changes in s_roundl.c to use bit twiddling. Reported by: ian
OpenPOWER on IntegriCloud