summaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-03-13 01:17:53 -0400
committerRich Felker <dalias@aerifal.cx>2012-03-13 01:17:53 -0400
commitb69f695acedd4ce2798ef9ea28d834ceccc789bd (patch)
treeeafd98b9b75160210f3295ac074d699f863d958e /src/stdlib
parentd46cf2e14cc4df7cc75e77d7009fcb6df1f48a33 (diff)
downloadmusl-b69f695acedd4ce2798ef9ea28d834ceccc789bd.tar.gz
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.
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/frexp.c23
-rw-r--r--src/stdlib/frexpf.c23
-rw-r--r--src/stdlib/frexpl.c37
3 files changed, 0 insertions, 83 deletions
diff --git a/src/stdlib/frexp.c b/src/stdlib/frexp.c
deleted file mode 100644
index ae82cb30..00000000
--- a/src/stdlib/frexp.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-#include <inttypes.h>
-
-double frexp(double x, int *e)
-{
- union { double d; uint64_t i; } y = { x };
- int ee = y.i>>52 & 0x7ff;
-
- if (!ee) {
- if (x) {
- x = frexp(x*0x1p64, e);
- *e -= 64;
- } else *e = 0;
- return x;
- } else if (ee == 0x7ff) {
- return x;
- }
-
- *e = ee - 0x3fe;
- y.i &= 0x800fffffffffffffull;
- y.i |= 0x3fe0000000000000ull;
- return y.d;
-}
diff --git a/src/stdlib/frexpf.c b/src/stdlib/frexpf.c
deleted file mode 100644
index ee5e910a..00000000
--- a/src/stdlib/frexpf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-#include <inttypes.h>
-
-float frexpf(float x, int *e)
-{
- union { float f; uint32_t i; } y = { x };
- int ee = y.i>>23 & 0xff;
-
- if (!ee) {
- if (x) {
- x = frexpf(x*0x1p64, e);
- *e -= 64;
- } else *e = 0;
- return x;
- } else if (ee == 0xff) {
- return x;
- }
-
- *e = ee - 0x7e;
- y.i &= 0x807ffffful;
- y.i |= 0x3f000000ul;
- return y.f;
-}
diff --git a/src/stdlib/frexpl.c b/src/stdlib/frexpl.c
deleted file mode 100644
index 3472bf70..00000000
--- a/src/stdlib/frexpl.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <math.h>
-#include <inttypes.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-
-/* This version is for 80-bit little endian long double */
-
-long double frexpl(long double x, int *e)
-{
- union { long double ld; uint16_t hw[5]; } y = { x };
- int ee = y.hw[4]&0x7fff;
-
- if (!ee) {
- if (x) {
- x = frexpl(x*0x1p64, e);
- *e -= 64;
- } else *e = 0;
- return x;
- } else if (ee == 0x7fff) {
- return x;
- }
-
- *e = ee - 0x3ffe;
- y.hw[4] &= 0x8000;
- y.hw[4] |= 0x3ffe;
- return y.ld;
-}
-
-#else
-
-long double frexpl(long double x, int *e)
-{
- return frexp(x, e);
-}
-
-#endif