diff --git a/lib/c/math.zig b/lib/c/math.zig index 1f379792a7c61145815193c33496872e118ea38b..1f80e1cc7e5362891884988ecff8423269bf9ce8 100644 --- a/lib/c/math.zig +++ b/lib/c/math.zig @@ -37,6 +37,7 @@ comptime { if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { symbol(&coshf, "coshf"); symbol(&frexpf, "frexpf"); + symbol(&frexpl, "frexpl"); symbol(&hypotf, "hypotf"); symbol(&hypotl, "hypotl"); symbol(&modff, "modff"); @@ -190,6 +191,10 @@ fn frexpf(x: f32, e: *c_int) callconv(.c) f32 { return frexpGeneric(f32, x, e); } +fn frexpl(x: c_longdouble, e: *c_int) callconv(.c) c_longdouble { + return frexpGeneric(c_longdouble, x, e); +} + fn hypot(x: f64, y: f64) callconv(.c) f64 { return math.hypot(x, y); } diff --git a/lib/libc/mingw/math/frexpl.c b/lib/libc/mingw/math/frexpl.c deleted file mode 100644 index f60b68bcde18c8fafd7451d0774f6b1aaa2aaaa2..0000000000000000000000000000000000000000 --- a/lib/libc/mingw/math/frexpl.c +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -long double frexpl(long double value, int* exp); - -#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ - -double frexp(double value, int* exp); - -/* On ARM `long double` is 64 bits. */ -long double frexpl(long double value, int* exp) -{ - return frexp(value, exp); -} - -#elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) - -#include - -/* https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format */ -typedef union x87reg_ { - struct __attribute__((__packed__)) { - uint64_t f64; - uint16_t exp : 15; - uint16_t sgn : 1; - }; - long double f; -} x87reg; - -long double frexpl(long double value, int* exp) -{ - int n; - x87reg reg; - reg.f = value; - if(reg.exp == 0x7FFF) { - /* The value is an infinity or NaN. - * Store zero in `*exp`. Return the value as is. */ - *exp = 0; - return reg.f; - } - if(reg.exp != 0) { - /* The value is normalized. - * Extract and zero out the exponent. */ - *exp = reg.exp - 0x3FFE; - reg.exp = 0x3FFE; - return reg.f; - } - if(reg.f64 == 0) { - /* The value is zero. - * Store zero in `*exp`. Return the value as is. - * Note the signness. */ - *exp = 0; - return reg.f; - } - /* The value is denormalized. - * Extract the exponent, normalize the value, then zero out - * the exponent. Note that x87 uses an explicit leading bit. */ - n = __builtin_clzll(reg.f64); - reg.f64 <<= n; - *exp = 1 - 0x3FFE - n; - reg.exp = 0x3FFE; - return reg.f; -} - -#else - -#error Please add `frexpl()` implementation for this platform. - -#endif diff --git a/lib/libc/musl/src/math/frexpl.c b/lib/libc/musl/src/math/frexpl.c deleted file mode 100644 index 3c1b553748eec19a18804362acd508d3877d7fb6..0000000000000000000000000000000000000000 --- a/lib/libc/musl/src/math/frexpl.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "libm.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double frexpl(long double x, int *e) -{ - return frexp(x, e); -} -#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 -long double frexpl(long double x, int *e) -{ - union ldshape u = {x}; - int ee = u.i.se & 0x7fff; - - if (!ee) { - if (x) { - x = frexpl(x*0x1p120, e); - *e -= 120; - } else *e = 0; - return x; - } else if (ee == 0x7fff) { - return x; - } - - *e = ee - 0x3ffe; - u.i.se &= 0x8000; - u.i.se |= 0x3ffe; - return u.f; -} -#endif diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index e9417eb9454b22a88ac4a4c9576b7ad6871576df..254f0e56212c86658317698ce493958291cc823d 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -613,7 +613,6 @@ const mingw32_generic_src = [_][]const u8{ "math" ++ path.sep_str ++ "fpclassify.c", "math" ++ path.sep_str ++ "fpclassifyf.c", "math" ++ path.sep_str ++ "fpclassifyl.c", - "math" ++ path.sep_str ++ "frexpl.c", "math" ++ path.sep_str ++ "ldexpf.c", "math" ++ path.sep_str ++ "lgamma.c", "math" ++ path.sep_str ++ "lgammaf.c", diff --git a/src/libs/musl.zig b/src/libs/musl.zig index 86e0995220842f3d6b35442c2bc497df26384522..73f93a82710d735f2b7998d27811c2d2be2dc0c9 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -839,7 +839,6 @@ const src_files = [_][]const u8{ "musl/src/math/__fpclassify.c", "musl/src/math/__fpclassifyf.c", "musl/src/math/__fpclassifyl.c", - "musl/src/math/frexpl.c", "musl/src/math/i386/acosl.s", "musl/src/math/i386/asinf.s", "musl/src/math/i386/asinl.s", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index d0743dbe3d10334e7aeafbef8c71bc3ae7043195..75840076a50064095e72ae64cdb46013ed756a5e 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -701,7 +701,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/finitef.c", "musl/src/math/fma.c", "musl/src/math/fmaf.c", - "musl/src/math/frexpl.c", "musl/src/math/ilogb.c", "musl/src/math/ilogbf.c", "musl/src/math/ilogbl.c",