Commit Graph

971 Commits

Author SHA1 Message Date
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
2cbb24bba3 remove junk sincos implementations in preparation to merge nsz's real ones 2012-03-16 20:53:05 -04:00
Rich Felker
a43c3a337f revert COPYRIGHT file changes in preparation to merge nsz's math branch 2012-03-16 20:52:00 -04:00
Rich Felker
6f21da618f update copyright status (math library and new year) 2012-03-16 19:18:00 -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
5657cc58e5 implement sincosf and sincosl functions; add prototypes
presumably broken gcc may generate calls to these, and it's said that
ffmpeg makes use of sincosf.
2012-03-15 02:38:42 -04: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
Rich Felker
291f839a44 fix scanf handling of "0" (followed by immediate EOF) with "%x"
other cases with %x were probably broken too.

I would actually like to go ahead and replace this code in scanf with
calls to the new __intparse framework, but for now this calls for a
quick and unobtrusive fix without the risk of breaking other things.
2012-03-13 12:37:51 -04:00
nsz
df8b3e5aef clean up __expo2.c, use a slightly better k constant 2012-03-13 16:38:22 +01:00
nsz
3a6c828652 fix copyright notice for the math lib 2012-03-13 16:06:43 +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
d46cf2e14c add .gitignore file
I've had this around for a long time but somehow it never got
committed.
2012-03-09 03:39:28 -05:00
Rich Felker
405ce58dcf fix nan/infinity macros in math.h, etc.
the previous version not only failed to work in c++, but also failed
to produce constant expressions, making the macros useless as
initializers for objects of static storage duration.

gcc 3.3 and later have builtins for these, which sadly seem to be the
most "portable" solution. the alternative definitions produce
exceptions (for NAN) and compiler warnings (for INFINITY) on newer
versions of gcc.
2012-03-02 22:35:37 -05:00
Rich Felker
b4a07bb469 fix obscure bug in strtoull reading the highest 16 possible values 2012-03-02 12:48:17 -05:00
Rich Felker
9fcecd7b34 typo in math.h c version check 2012-03-02 11:38:39 -05:00
Rich Felker
db3e78cee5 make math.h compatibe with c89 2012-03-02 00:36:26 -05:00
Rich Felker
6cf51fe51a remove debug cruft that was left in getdate 2012-03-02 00:24:49 -05:00
Rich Felker
b93b7382d6 first try at implementing getdate function 2012-03-02 00:24:17 -05:00
Rich Felker
536db2b5ac fix bugs in strptime handling of string day/month names, literals 2012-03-02 00:23:43 -05:00
Rich Felker
ca19774c91 implement a64l and l64a (legacy xsi stuff) 2012-03-01 23:43:31 -05:00
Rich Felker
e0614f7cd4 add all missing wchar functions except floating point parsers
these are mostly untested and adapted directly from corresponding byte
string functions and similar.
2012-03-01 23:24:45 -05:00
Rich Felker
899b13cae7 support null buffer argument to getcwd, auto-allocating behavior
this is a popular extension some programs depend on, and by using a
temporary buffer and strdup rather than malloc prior to the syscall,
i've avoided the dependency on free and thus minimized the bloat cost
of supporting this feature.
2012-03-01 22:08:05 -05:00
Rich Felker
051175d4fe add memory.h, bogus legacy alias for string.h 2012-03-01 01:34:58 -05:00
Rich Felker
15d143b547 search internal headers first
this is necessitated by the ugly <syscall.h> just added
2012-03-01 00:21:20 -05:00
Rich Felker
d36751943a use c++-friendly initializers for pthread initializer definitions
these will also avoid obnoxious warnings with gcc -Wbraces.
2012-02-29 22:55:08 -05:00
Rich Felker
4ce6766a32 add <syscall.h> as an alias for <sys/syscall.h>
apparently some broken stuff (libstdc++) needs this.
2012-02-29 22:36:06 -05:00
Rich Felker
95b930ad26 implement wcsftime function 2012-02-28 15:59:01 -05:00
Rich Felker
b1a8e0d454 release notes for 0.8.6 2012-02-28 11:56:13 -05:00
Rich Felker
e3234d0109 fix pthread_cleanup_pop(1) crash in non-thread-capable, static-linked programs 2012-02-28 10:13:35 -05:00
Rich Felker
aab33ec0a3 update release notes for 0.8.5 2012-02-27 20:12:06 -05:00
Rich Felker
dac084a4c5 work around "signal loses thread pointer" issue with "approach 2"
this was discussed on the mailing list and no consensus on the
preferred solution was reached, so in anticipation of a release, i'm
just committing a minimally-invasive solution that avoids the problem
by ensuring that multi-threaded-capable programs will always have
initialized the thread pointer before any signal handler can run.

in the long term we may switch to initializing the thread pointer at
program start time whenever the program has the potential to access
any per-thread data.
2012-02-27 18:51:02 -05:00
Rich Felker
834255a3ff use __attribute__((const)) on arm __pthread_self function 2012-02-25 02:52:18 -05:00
Rich Felker
06aec8d715 replace prototype for basename in string.h with non-prototype declaration
GNU programs may expect the GNU version of basename, which has a
different prototype (argument is const-qualified) and prototype it
themselves too. of course if they're expecting the GNU behavior for
the function, they'll still run into problems, but at least this
eliminates some compile-time failures.
2012-02-24 23:23:47 -05:00
Rich Felker
78e79d9d50 new attempt at working around the gcc 3 visibility bug
since gcc is failing to generate the necessary ".hidden" directive in
the output asm, generate it explicitly with an __asm__ statement...
2012-02-24 20:07:21 -05:00
Rich Felker
7fa29920ed remove useless attribute visibility from definitions
this was a failed attempt at working around the gcc 3 visibility bug
affecting x86_64. subsequent patch will address it with an ugly but
working hack.
2012-02-24 20:02:42 -05:00
Rich Felker
bae2e52bfd cleanup and work around visibility bug in gcc 3 that affects x86_64
in gcc 3, the visibility attribute must be placed on both the
declaration and on the definition. if it's omitted from the
definition, the compiler fails to emit the ".hidden" directive in the
assembly, and the linker will either generate textrels (if supported,
such as on i386) or refuse to link (on targets where certain types of
textrels are forbidden or impossible without further assumptions about
memory layout, such as on x86_64).

this patch also unifies the decision about when to use visibility into
libc.h and makes the visibility in the utf-8 state machine tables
based on libc.h rather than a duplicate test.
2012-02-23 21:24:56 -05:00
Rich Felker
00b883a955 fix (hopefully) PTRACE_TRACEME (command 0) argument handling 2012-02-23 13:08:47 -05:00