Commit Graph
25 Commits
Author SHA1 Message Date
Rich Felker d3fc724759 one more fenv availability issue: lround 2012-03-17 00:02:36 -04:00
Rich Felker 2e77dc13f8 make fma and lrint functions build without full fenv support
this is necessary to support archs where fenv is incomplete or
unavailable (presently arm). fma, fmal, and the lrint family should
work perfectly fine with this change; fmaf is slightly broken with
respect to rounding as it depends on non-default rounding modes to do
its work.
2012-03-16 23:58:49 -04:00
Rich Felker 8c071f872b other side of the signgam namespace fix: use the internal name 2012-03-16 21:20:53 -04:00
Rich Felker 1a3dce4184 make signgam a weak alias for an internal symbol
otherwise, the standard C lgamma function will clobber a symbol in the
namespace reserved for the application.
2012-03-16 21:18:48 -04:00
Rich Felker de7db6e927 fix namespace issues for lgamma, etc.
standard functions cannot depend on nonstandard symbols
2012-03-16 21:16:32 -04:00
Rich Felker 93a50a26cd Merge remote branch 'nsz/master' 2012-03-16 21:01:34 -04:00
Rich Felker 9d507419db remove special nan handling from x86 sqrt asm
a double precision nan, when converted to extended (80-bit) precision,
will never end in 0x400, since the corresponding bits do not exist in
the original double precision value. thus there's no need to waste
time and code size on this check.
2012-03-15 19:56:36 -04:00
Rich Felker 1295848efb simplify nan check in sqrt (x86 asm); result of sqrt is never negative 2012-03-15 12:16:51 -04:00
nsz 40305f74bd in math.h make lgamma_r and non-double bessel _GNU_SOURCE only
long double and float bessel functions are no longer xsi extensions
2012-03-15 09:29:53 +01:00
nsz 0144b45b71 efficient sincos based on sin and cos 2012-03-15 08:17:28 +01:00
Rich Felker 46702f68f9 avoid changing NaNs in sqrt (x86 asm) to satisfy c99 f.9 recommendation 2012-03-15 01:55:54 -04:00
Rich Felker 809556e60a correctly rounded sqrt() asm for x86 (i387)
the fsqrt opcode is correctly rounded, but only in the fpu's selected
precision mode, which is 80-bit extended precision. to get a correctly
rounded double precision output, we check for the only corner cases
where two-step rounding could give different results than one-step
(extended-precision mantissa ending in 0x400) and adjust the mantissa
slightly in the opposite direction of the rounding which the fpu
already did (reported in the c1 flag of the fpu status word).

this should have near-zero cost in the non-corner cases and at worst
very low cost.

note that in order for sqrt() to get used when compiling with gcc, the
broken, non-conformant builtin sqrt must be disabled.
2012-03-15 01:29:03 -04:00
Rich Felker e0a54e6725 correct rounding for i387 sqrtf function 2012-03-13 22:15:52 -04:00
nsz 32ca5ef3ff math cleanup: use 1.0f instead of 1.0F 2012-03-13 21:11:46 +01:00
nsz 8d0a6f7a1c math cleanup: use 1.0f instead of (float)1.0 2012-03-13 20:24:23 +01:00
nsz 9560b6b152 remove libm.h includes when math.h and float.h are enough 2012-03-13 19:51:14 +01:00
nsz df8b3e5aef clean up __expo2.c, use a slightly better k constant 2012-03-13 16:38:22 +01:00
Rich Felker bf9d9dcaa6 implement nan, nanf, nanl 2012-03-13 01:55:25 -04:00
Rich Felker b69f695ace first commit of the new libm!
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best
(from correctness and license standpoint) implementations from freebsd
and openbsd and cleaning them up! musl should now fully support c99
float and long double math functions, and has near-complete complex
math support. tgmath should also work (fully on gcc-compatible
compilers, and mostly on any c99 compiler).

based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from
nsz's libm git repo, with some additions (dummy versions of a few
missing long double complex functions, etc.) by me.

various cleanups still need to be made, including re-adding (if
they're correct) some asm functions that were dropped.
2012-03-13 01:17:53 -04:00
Rich Felker daaef3552d fix error in previous ld80 fpclassify commit 2011-06-30 16:37:51 -04:00
Rich Felker f6fd351c70 catch invalid ld80 bit patterns and treat them as nan
this should not be necessary - the invalid bit patterns cannot be
created except through type punning. however, some broken gnu software
is passing them to printf and triggering dangerous stack-smashing, so
let's catch them anyway...
2011-06-30 16:31:43 -04:00
Rich Felker bc30aea457 type directives for x86_64 math asm 2011-06-26 17:41:34 -04:00
Rich Felker e22c2d3ee6 use .type directives for math asm (needed for dynamic linking to work) 2011-06-26 15:52:37 -04:00
Nicholas J. Kain 1e12632591 Port musl to x86-64. One giant commit! 2011-02-15 07:32:09 -05:00
Rich Felker 0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00