master
Fix ilogb(3) implementation. The results have to match FP_ILOGB0 and FP_ILOGBNAN which isn't the case for the amd64 and i386 assembly versions. Drop these in favour of C implementations. Als reimplement ilogbl(3) by providing separate ld80 and ld128 implementations that replace the existing implementation which may hit an infinite loop when built for quad-precision long double.
spelling fixes; from paul tagliamonte any changes not taken noted on tech, but chiefly here i did not take the cancelation - cancellation changes;
Per fpclassify(3): isinff(), isnanf(), finite(), and finitef() are deprecated in favor of isinf(), isnan(), and isfinite().
rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
Reduce libm's exports and make internal calls go direct. All dependencies on libc are now via reserved/standardized names.
- 80-bit and quad precision trigonometric and other most important functions: acosl, asinl, atanl, atan2l, cosl, sinl, tanl, exp2l, frexpl, ilogbl, ldexpl, logbl, scalbnl, fabsl, hypotl, powl, sqrtl, rintl, copysignl, nanl, fdiml, fmaxl, fminl. mostly taken from freebsd, needed alot of changes to adapt. note, these are all c versions; and are quite slow when architectures have, e.g. sqrt. assembly versions will be added afterwards - make them .weak/__weak_alias to the double precision versions on other archs - no need to have two finites. finite() and finitef() are non-standard 3BSD obsolete versions of isfinite. remove from libm. make them weak_alias in libc to __isfinite and __isfinitef instead. similarly make 3BSD obsolete versions of isinf, isinff, isnan, isnanf weak_aliases to C99's __isinf, __isinff, __isnan, __isnanf - remove unused infinity.c. the c library has infinities for each supported platform - use STRICT_ASSIGN cast hack for _kernel_rem_pio2, so that the double version has a chance of working on i386 with extra precision - avoid storing multiple copies of the pi/2 array, since it won't vary - bump major due to removed finite/finitef. although they will be in libc, which anything is linked to, minor bump might be enough ok millert@. tested by sthen@, jsg@, ajacoutot@, kili@, naddy@
- replace dtoa w/ David's gdtoa, version 2008-03-15 - provide proper dtoa locks - use the real strtof implementation - add strtold, __hdtoa, __hldtoa - add %a/%A support - don't lose precision in printf, don't round to double anymore - implement extended-precision versions of libc functions: fpclassify, isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is fixed - separate vax versions of strtof, and __hdtoa - add complex math support. added functions: cacos, casin, catan, ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp, clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf, casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf, ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf, cimagf, conjf, cprojf, crealf - add fdim, fmax, fmin - add log2. (adapted implementation e_log.c. could be more acruate & faster, but it's good enough for now) - remove wrappers & cruft in libm, supposed to work-around mistakes in SVID, etc.; use ieee versions. fixes issues in python 2.6 for djm@ - make _digittoint static - proper definitions for i386, and amd64 in ieee.h - sh, powerpc don't really have extended-precision - add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h for LDBL_* - merge lead to frac for m{6,8}k, for gdtoa to work properly - add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa to use - add EXT_IMPLICIT_NBIT definition, which indicates implicit normalization bit - add regression tests for libc: fpclassify and printf - arith.h & gd_qnan.h definitions - update ieee.h: hppa doesn't have quad-precision, hppa64 does - add missing prototypes to gdtoaimp - on 64-bit platforms make sure gdtoa doesn't use a long when it really wants an int - etc., what i may have forgotten... - bump libm major, due to removed&changed symbols - no libc bump, since this is riding on djm's libc major crank from a day ago
Finalize work on the math library. It's time to do this monster commit, and deal with problems (if any) in tree.
Copy cos(3) software implementation from FreeBSD-13
Optimization for tiny x in cos and sin
Implement sicos(3), sincosf(3) and sincosl(3). These functions are common extensions and modern compilers (such as clang) will use them to optimize separate calculations of sine and cosine.
Declare __p1evll and __polevll protos in math_private.h instead of redeclaring each time in ld{80,128}. Pointed out by theo.
repair confusing "} if" indentation as suggested by deraadt@
For intermediate computations use single or extended counterparts where appropriate, to avoid precision loss.
Signs of cacosh/cacoshf were not always correct (e.g., -1.1 -1.1i), as found by fortran regression tests. Also added some complex regression tests for cacosh, casinh, catanh. Reported by John Marino @ DragonFlyBSD.
Adapt previous to extended-precision, and fix single-precision constants.
- Make constants const. - Fix aliasing issue in s_frexpf.c; spotted by gcc. Many other ones were fixed in NetBSD long ago, but this one was forgotten. It looks like recently they fixed it too.
Finalize work on complex math routines, now that we have the extended-precision support. Mostly from Cephes.
Use crealf() and cimagf() instead of creal() and cimag() when the argument is a float. Eliminate a cast rendered superfluous as a result.
Call the single, not double-precision version of copysign for the float arguments.
Remove excessive sys/cdefs.h inclusion ok guenther millert kettenis
Add parentheses around comparison in operand of ^. Pointed out by theo.
Add explicit braces to avoid ambiguous else. Pointed out by theo.
Replace lrint(3), lrintf(3), llrint(3) and llrintf(3) implementations with the same implementation that we're already using for lrintl(3) and llrintl(3). The old implementations were derived from code from NetBSD that didn't pass the lib/libm/msun/lrint_test regress test. NetBSD replaced their implementation with the FreeBSD implementation of this code which we were already using for lrintl(3) and llrintl(3). This fixes the regress test.
rename lround.c lroundf.c llround.c llroundf.c to s_lround.c s_lroundf.c s_llround.c s_llroundf.c, for naming consistency looks fine to millert@
Provide logbl(3) when long double is double
The {,l}lround{,f} implementations are based on {,l}lrint{,f}, therefore affected by the same bugs I've fixed a week ago.
Revert previous. bluhm noted that it causes a regress failure.
Make sure modff() returns correct values for infinities.
- enable fenv - add nearbyint, nearbyintf and nearbyintl implemented using fenv
C99: "The nextafter functions return y if x equals y."
Trick the compiler that volatile temporary is used while raising the underflow.
Gah, rintl() is used internally, so add a macro for the fourth possiblity, a cloning a non-standard, long double function which _is_ used from the matching plain double function
int is big enough to fully represent exponents of all supported fp formats. which even for 80-bit & 128-bit long doubles is only 15 bits. therefore, scalbln, scalblnf, scalblnl are essentially the same as scalbn, scalbnf, scalbnl with bounds checking so that LONG_MIN..INT_MIN, and INT_MAX..LONG_MAX ranges properly raise exceptions & yield correct values. looks good to millert@
Fix build of sincosl on machines where long double == double
add return statements missed when adapting from FreeBSD
For tiny x, tanhf = x*(one+x). GCC (at -O2) optimized this into x+x*x, as a result sign got lost for the zero inputs. Explicitly return in this case, similarly like has been done in tanh.
convert to ansi function decl
lint prefers ANSI C function definitions if a prototype is available; i can only agree