commit 5082e85de95d491b52fbff2c64cfd5b7190ddc10 (tree) parent 9a7f14354e30c3f66135f07ba721c232e79f3740 Author: Andrew Kelley <andrew@ziglang.org> Date: Sat, 10 Jan 2026 22:15:32 +0100 Merge pull request 'libc: use compiler_rt/libzigc for some math functions and add some libc-tests' (#30767) from rpkak/zig:libc-compiler_rt-math into master Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30767 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Diffstat:
101 files changed, 268 insertions(+), 2695 deletions(-)
diff --git a/lib/c/math.zig b/lib/c/math.zig @@ -32,6 +32,12 @@ comptime { @export(&nanf, .{ .name = "nanf", .linkage = common.linkage, .visibility = common.visibility }); @export(&nanl, .{ .name = "nanl", .linkage = common.linkage, .visibility = common.visibility }); } + + if (builtin.target.isMuslLibC()) { + @export(©signf, .{ .name = "copysignf", .linkage = common.linkage, .visibility = common.visibility }); + @export(©sign, .{ .name = "copysign", .linkage = common.linkage, .visibility = common.visibility }); + } + @export(©signl, .{ .name = "copysignl", .linkage = common.linkage, .visibility = common.visibility }); } fn isnan(x: f64) callconv(.c) c_int { @@ -57,3 +63,15 @@ fn nanf(_: [*:0]const c_char) callconv(.c) f32 { fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble { return std.math.nan(c_longdouble); } + +fn copysignf(x: f32, y: f32) callconv(.c) f32 { + return std.math.copysign(x, y); +} + +fn copysign(x: f64, y: f64) callconv(.c) f64 { + return std.math.copysign(x, y); +} + +fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { + return std.math.copysign(x, y); +} diff --git a/lib/compiler_rt/sqrt.zig b/lib/compiler_rt/sqrt.zig @@ -54,7 +54,7 @@ pub fn __sqrth(x: f16) callconv(.c) f16 { // m: 2.14 r: 0.16, s: 2.14, d: 2.14, u: 2.14, three: 2.14 const three: u16 = 0xC000; const i: usize = @intCast((ix >> 4) & 0x7F); - const r = __rsqrt_tab[i]; + const r = rsqrt_tab[i]; // |r*sqrt(m) - 1| < 0x1p-8 var s = mul16(m, r); // |s/sqrt(m) - 1| < 0x1p-8 @@ -92,74 +92,56 @@ pub fn __sqrth(x: f16) callconv(.c) f16 { pub fn sqrtf(x: f32) callconv(.c) f32 { var ix: u32 = @bitCast(x); - var top = ix >> 23; - // special case handling. - if (top -% 0x01 >= 0xFF - 0x01) { + if (ix < @as(u32, @bitCast(@as(f32, 0x1p-126))) or @as(u32, @bitCast(std.math.inf(f32))) <= ix) { @branchHint(.unlikely); - // x < 0x1p-126 or inf or nan. - if (ix & 0x7FFF_FFFF == 0) return x; - if (ix == 0x7F80_0000) return x; - if (ix > 0x7F80_0000) return math.nan(f32); - // x is subnormal, normalize it. - ix = @bitCast(x * 0x1p23); - top = (ix >> 23) -% 23; + + if (ix & 0x7fffffff == 0) + return x; + + if (ix == @as(u32, @bitCast(std.math.inf(f32)))) + return x; + + if (ix > @as(u32, @bitCast(std.math.inf(f32)))) + return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f32); + + ix = @as(u32, @bitCast(@as(i32, @bitCast(x * 0x1p23)) - (23 << 23))); } - // argument reduction: - // x = 4^e m; with integer e, and m in [1, 4) - // m: fixed point representation [2.30] - // 2^e is the exponent part of the result. - const even = (top & 1) != 0; - const m = if (even) (ix << 7) & 0x7FFF_FFFF else (ix << 8) | 0x8000_0000; - top = (top +% 0x7F) >> 1; + const m: u32 = if (ix & 0x00800000 != 0) + (ix << 7) & 0x7fffffff + else + (ix << 8) | 0x80000000; + + const ey = ((ix >> 1) + (0x3f800000 >> 1)) & 0x7f800000; + // const ey = ((ix + 0x3f800000) & 0xff000000) >> 1; + + const three = 0xc0000000; + const i = (ix >> 17) & 0x7f; + var r = @as(u32, rsqrt_tab[i]) << 16; - // approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4) - // the fixed point representations are - // m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 - const three: u32 = 0xC000_0000; - var i: usize = @intCast((ix >> 17) & 0x3F); - if (even) i += 64; - var r = @as(u32, @intCast(__rsqrt_tab[i])) << 16; - // |r*sqrt(m) - 1| < 0x1p-8 var s = mul32(m, r); - // |s/sqrt(m) - 1| < 0x1p-8 var d = mul32(s, r); var u = three - d; r = mul32(r, u) << 1; - // |r*sqrt(m) - 1| < 0x1.7bp-16 s = mul32(s, u) << 1; - // |s/sqrt(m) - 1| < 0x1.7bp-16 d = mul32(s, r); u = three - d; - s = mul32(s, u); // repr: 3.29 - // -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 - s = (s - 1) >> 6; // repr: 9.23 - // s < sqrt(m) < s + 0x1.08p-23 + s = mul32(s, u); + s = (s - 1) >> 6; - // compute nearest rounded result: - // the nearest result to 23 bits is either s or s+0x1p-23, - // we can decide by comparing (2^23 s + 0.5)^2 to 2^46 m. const d0 = (m << 16) -% s *% s; const d1 = s -% d0; const d2 = d1 +% s +% 1; - s += d1 >> 31; - s &= 0x007F_FFFF; - s |= top << 23; - const y: f32 = @bitCast(s); + const y: f32 = @bitCast(((s + (d1 >> 31)) & 0x007fffff) | ey); - // handle rounding modes and inexact exception: - // only (s+1)^2 == 2^16 m case is exact otherwise - // add a tiny value to cause the fenv effects. - if (d2 != 0) { - @branchHint(.likely); - var tiny: u32 = 0x0100_0000; - tiny |= (d1 ^ d2) & 0x8000_0000; - const t: f32 = @bitCast(tiny); - return y + t; - } + const tiny: u32 = if (d2 == 0) blk: { + @branchHint(.unlikely); + break :blk 0; + } else 0x01000000; + const t: f32 = @bitCast(tiny | ((d1 ^ d2) & 0x80000000)); - return y; + return y + t; } pub fn sqrt(x: f64) callconv(.c) f64 { @@ -172,7 +154,7 @@ pub fn sqrt(x: f64) callconv(.c) f64 { // x < 0x1p-1022 or inf or nan. if (ix & 0x7FFF_FFFF_FFFF_FFFF == 0) return x; if (ix == 0x7FF0_0000_0000_0000) return x; - if (ix > 0x7FF0_0000_0000_0000) return math.nan(f64); + if (ix > 0x7FF0_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); // x is subnormal, normalize it. ix = @bitCast(x * 0x1p52); top = (ix >> 52) -% 52; @@ -248,7 +230,7 @@ pub fn sqrt(x: f64) callconv(.c) f64 { var d: struct { u32, u64 } = undefined; var u: struct { u32, u64 } = undefined; const i: usize = @intCast((ix >> 46) & 0x7F); - r[0] = @intCast(__rsqrt_tab[i]); + r[0] = @intCast(rsqrt_tab[i]); r[0] <<= 16; // |r sqrt(m) - 1| < 0x1.fdp-9 s[0] = mul32(@intCast(m >> 32), r[0]); @@ -309,7 +291,7 @@ pub fn __sqrtx(x: f80) callconv(.c) f80 { // x < 0x1p-16382 or inf or nan. if (ix & 0x7FFF_FFFF_FFFF_FFFF_FFFF == 0) return x; if (ix == 0x7FFF_8000_0000_0000_0000) return x; - if (ix > 0x7FFF_8000_0000_0000_0000) return math.nan(f80); + if (ix > 0x7FFF_8000_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f80); // x is subnormal, normalize it. ix = @bitCast(x * 0x1p63); top = (ix >> 64) -% 63; @@ -341,7 +323,7 @@ pub fn __sqrtx(x: f80) callconv(.c) f80 { var u: struct { u32, u64, u80 } = undefined; var i: usize = @intCast((ix >> 57) & 0x3F); if (even) i += 64; - r[0] = @intCast(__rsqrt_tab[i]); + r[0] = @intCast(rsqrt_tab[i]); r[0] <<= 16; // |r sqrt(m) - 1| < 0x1p-8 s[0] = mul32(@intCast(m >> 48), r[0]); @@ -437,7 +419,7 @@ pub fn sqrtq(x: f128) callconv(.c) f128 { var d: struct { u32, u64, u128 } = undefined; var u: struct { u32, u64, u128 } = undefined; const i: usize = @intCast((ix >> 106) & 0x7F); - r[0] = @intCast(__rsqrt_tab[i]); + r[0] = @intCast(rsqrt_tab[i]); r[0] <<= 16; // |r sqrt(m) - 1| < 0x1p-8 s[0] = mul32(@intCast(m >> 96), r[0]); @@ -507,7 +489,7 @@ pub fn sqrtl(x: c_longdouble) callconv(.c) c_longdouble { } } -const __rsqrt_tab: [128]u16 = .{ +const rsqrt_tab: [128]u16 = .{ 0xB451, 0xB2F0, 0xB196, 0xB044, 0xAEF9, 0xADB6, 0xAC79, 0xAB43, 0xAA14, 0xA8EB, 0xA7C8, 0xA6AA, 0xA592, 0xA480, 0xA373, 0xA26B, 0xA168, 0xA06A, 0x9F70, 0x9E7B, 0x9D8A, 0x9C9D, 0x9BB5, 0x9AD1, @@ -527,15 +509,15 @@ const __rsqrt_tab: [128]u16 = .{ }; inline fn mul16(a: u16, b: u16) u16 { - return @intCast(@as(u32, @intCast(a)) * @as(u32, @intCast(b)) >> 16); + return @intCast(@as(u32, a) * b >> 16); } inline fn mul32(a: u32, b: u32) u32 { - return @intCast(@as(u64, @intCast(a)) * @as(u64, @intCast(b)) >> 32); + return @intCast(@as(u64, a) * b >> 32); } inline fn mul64(a: u64, b: u64) u64 { - return @intCast(@as(u128, @intCast(a)) * @as(u128, @intCast(b)) >> 64); + return @intCast(@as(u128, a) * b >> 64); } inline fn mul80(a: u80, b: u80) u80 { diff --git a/lib/libc/mingw/math/copysign.c b/lib/libc/mingw/math/copysign.c @@ -1,21 +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. - */ -#include <math.h> - -typedef union U -{ - unsigned int u[2]; - double d; -} U; - -double copysign(double x, double y) -{ - U h,j; - h.d = x; - j.d = y; - h.u[1] = (h.u[1] & 0x7fffffff) | (j.u[1] & 0x80000000); - return h.d; -} diff --git a/lib/libc/mingw/math/copysignf.c b/lib/libc/mingw/math/copysignf.c @@ -1,19 +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. - */ -#include <math.h> - -typedef union ui_f { - float f; - unsigned int ui; -} ui_f; - -float copysignf(float aX, float aY) -{ - ui_f x,y; - x.f=aX; y.f=aY; - x.ui= (x.ui & 0x7fffffff) | (y.ui & 0x80000000); - return x.f; -} diff --git a/lib/libc/mingw/math/fmaxl.c b/lib/libc/mingw/math/fmaxl.c @@ -1,12 +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. - */ -#include <math.h> - -long double -fmaxl (long double _x, long double _y) -{ - return (( isgreaterequal(_x, _y) || __isnanl (_y)) ? _x : _y ); -} diff --git a/lib/libc/mingw/math/fminl.c b/lib/libc/mingw/math/fminl.c @@ -1,12 +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. - */ -#include <math.h> - -long double -fminl (long double _x, long double _y) -{ - return ((islessequal(_x, _y) || __isnanl (_y)) ? _x : _y ); -} diff --git a/lib/libc/mingw/math/sqrt.def.h b/lib/libc/mingw/math/sqrt.def.h @@ -1,92 +0,0 @@ -/* - This Software is provided under the Zope Public License (ZPL) Version 2.1. - - Copyright (c) 2009, 2010 by the mingw-w64 project - - See the AUTHORS file for the list of contributors to the mingw-w64 project. - - This license has been certified as open source. It has also been designated - as GPL compatible by the Free Software Foundation (FSF). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions in source code must retain the accompanying copyright - notice, this list of conditions, and the following disclaimer. - 2. Redistributions in binary form must reproduce the accompanying - copyright notice, this list of conditions, and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - 3. Names of the copyright holders must not be used to endorse or promote - products derived from this software without prior written permission - from the copyright holders. - 4. The right to distribute this software or to use it for any purpose does - not give you the right to use Servicemarks (sm) or Trademarks (tm) of - the copyright holders. Use of them is covered by separate agreement - with the copyright holders. - 5. If any files are modified, you must cause the modified files to carry - prominent notices stating that you changed the files and the date of - any change. - - Disclaimer - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "../complex/complex_internal.h" -#include <errno.h> - -__FLT_TYPE -__FLT_ABI (sqrt) (__FLT_TYPE x) -{ - __FLT_TYPE res = __FLT_CST (0.0); - int x_class = fpclassify (x); - if (x_class == FP_NAN || signbit (x)) - { - if (x_class == FP_ZERO) - return __FLT_CST (-0.0); - - if (x_class == FP_NAN) - { - __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x); - return x; - } - - res = -__FLT_NAN; - __FLT_RPT_DOMAIN ("sqrt", x, 0.0, res); - return res; - } - else if (x_class == FP_ZERO) - return __FLT_CST (0.0); - else if (x_class == FP_INFINITE) - return __FLT_HUGE_VAL; - else if (x == __FLT_CST (1.0)) - return __FLT_CST (1.0); -#if defined(__arm__) || defined(_ARM_) -#if _NEW_COMPLEX_FLOAT - asm volatile ("fsqrts %[dst], %[src];\n" : [dst] "=t" (res) : [src] "t" (x)); -#else - asm volatile ("fsqrtd %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x)); -#endif -#elif defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) -#if _NEW_COMPLEX_FLOAT - asm volatile ("fsqrt %s[dst], %s[src]\n" : [dst] "=w" (res) : [src] "w" (x)); -#else - asm volatile ("fsqrt %d[dst], %d[src]\n" : [dst] "=w" (res) : [src] "w" (x)); -#endif -#elif defined(_X86_) || defined(__i386__) || defined(_AMD64_) || defined(__x86_64__) - asm volatile ("fsqrt" : "=t" (res) : "0" (x)); -#else -#error Not supported on your platform yet -#endif - return res; -} diff --git a/lib/libc/mingw/math/sqrtf.c b/lib/libc/mingw/math/sqrtf.c @@ -1,46 +0,0 @@ -/* - This Software is provided under the Zope Public License (ZPL) Version 2.1. - - Copyright (c) 2009, 2010 by the mingw-w64 project - - See the AUTHORS file for the list of contributors to the mingw-w64 project. - - This license has been certified as open source. It has also been designated - as GPL compatible by the Free Software Foundation (FSF). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions in source code must retain the accompanying copyright - notice, this list of conditions, and the following disclaimer. - 2. Redistributions in binary form must reproduce the accompanying - copyright notice, this list of conditions, and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - 3. Names of the copyright holders must not be used to endorse or promote - products derived from this software without prior written permission - from the copyright holders. - 4. The right to distribute this software or to use it for any purpose does - not give you the right to use Servicemarks (sm) or Trademarks (tm) of - the copyright holders. Use of them is covered by separate agreement - with the copyright holders. - 5. If any files are modified, you must cause the modified files to carry - prominent notices stating that you changed the files and the date of - any change. - - Disclaimer - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _NEW_COMPLEX_FLOAT 1 -#include "sqrt.def.h" diff --git a/lib/libc/mingw/math/sqrtl.c b/lib/libc/mingw/math/sqrtl.c @@ -1,46 +0,0 @@ -/* - This Software is provided under the Zope Public License (ZPL) Version 2.1. - - Copyright (c) 2009, 2010 by the mingw-w64 project - - See the AUTHORS file for the list of contributors to the mingw-w64 project. - - This license has been certified as open source. It has also been designated - as GPL compatible by the Free Software Foundation (FSF). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions in source code must retain the accompanying copyright - notice, this list of conditions, and the following disclaimer. - 2. Redistributions in binary form must reproduce the accompanying - copyright notice, this list of conditions, and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - 3. Names of the copyright holders must not be used to endorse or promote - products derived from this software without prior written permission - from the copyright holders. - 4. The right to distribute this software or to use it for any purpose does - not give you the right to use Servicemarks (sm) or Trademarks (tm) of - the copyright holders. Use of them is covered by separate agreement - with the copyright holders. - 5. If any files are modified, you must cause the modified files to carry - prominent notices stating that you changed the files and the date of - any change. - - Disclaimer - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _NEW_COMPLEX_LDOUBLE 1 -#include "sqrt.def.h" diff --git a/lib/libc/mingw/math/x86/copysignl.S b/lib/libc/mingw/math/x86/copysignl.S @@ -1,44 +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. - */ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Changes for long double by Ulrich Drepper <drepper@cygnus.com> - * Public domain. - */ -#include <_mingw_mac.h> - - .file "copysignl.S" - .text -#ifdef __x86_64__ - .align 8 -#else - .align 4 -#endif - - .globl __MINGW_USYMBOL(copysignl) - .def __MINGW_USYMBOL(copysignl); .scl 2; .type 32; .endef -__MINGW_USYMBOL(copysignl): -#if defined(_AMD64_) || defined(__x86_64__) - movq (%rdx), %rax - movq %rax, (%rcx) - movq 8(%rdx), %rax - movq 8(%r8), %rdx - andq $0x7fff, %rax - andq $0x8000, %rdx - orq %rdx, %rax - movq %rax, 8(%rcx) - movq %rcx, %rax - ret -#elif defined(_X86_) || defined(__i386__) - movl 24(%esp),%edx - movl 12(%esp),%eax - andl $0x8000,%edx - andl $0x7fff,%eax - orl %edx,%eax - movl %eax,12(%esp) - fldt 4(%esp) - ret -#endif diff --git a/lib/libc/mingw/math/x86/fmodf.c b/lib/libc/mingw/math/x86/fmodf.c @@ -1,29 +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. - */ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * - * Adapted for float type by Danny Smith - * <dannysmith@users.sourceforge.net>. - */ - -#include <math.h> - -float -fmodf (float x, float y) -{ - float res = 0.0F; - - asm volatile ( - "1:\tfprem\n\t" - "fstsw %%ax\n\t" - "sahf\n\t" - "jp 1b\n\t" - "fstp %%st(1)" - : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)"); - return res; -} diff --git a/lib/libc/mingw/math/x86/fmodl.c b/lib/libc/mingw/math/x86/fmodl.c @@ -1,21 +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 fmodl (long double x, long double y); - -long double -fmodl (long double x, long double y) -{ - long double res = 0.0L; - - asm volatile ( - "1:\tfprem\n\t" - "fstsw %%ax\n\t" - "sahf\n\t" - "jp 1b\n\t" - "fstp %%st(1)" - : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)"); - return res; -} diff --git a/lib/libc/mingw/math/x86/log.c b/lib/libc/mingw/math/x86/log.c @@ -1,46 +0,0 @@ -/* - This Software is provided under the Zope Public License (ZPL) Version 2.1. - - Copyright (c) 2009, 2010 by the mingw-w64 project - - See the AUTHORS file for the list of contributors to the mingw-w64 project. - - This license has been certified as open source. It has also been designated - as GPL compatible by the Free Software Foundation (FSF). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions in source code must retain the accompanying copyright - notice, this list of conditions, and the following disclaimer. - 2. Redistributions in binary form must reproduce the accompanying - copyright notice, this list of conditions, and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - 3. Names of the copyright holders must not be used to endorse or promote - products derived from this software without prior written permission - from the copyright holders. - 4. The right to distribute this software or to use it for any purpose does - not give you the right to use Servicemarks (sm) or Trademarks (tm) of - the copyright holders. Use of them is covered by separate agreement - with the copyright holders. - 5. If any files are modified, you must cause the modified files to carry - prominent notices stating that you changed the files and the date of - any change. - - Disclaimer - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _NEW_COMPLEX_DOUBLE 1 -#include "log.def.h" diff --git a/lib/libc/mingw/math/x86/log2f.S b/lib/libc/mingw/math/x86/log2f.S @@ -1,85 +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. - */ -#include <_mingw_mac.h> - - .file "log2f.S" - .text -#ifdef __x86_64__ - .align 8 -#else - .align 4 -#endif -one: .double 1.0 - /* It is not important that this constant is precise. It is only - a value which is known to be on the safe side for using the - fyl2xp1 instruction. */ -limit: .double 0.29 - -.globl __MINGW_USYMBOL(log2f) - .def __MINGW_USYMBOL(log2f); .scl 2; .type 32; .endef -__MINGW_USYMBOL(log2f): -#ifdef __x86_64__ - movss %xmm0,-12(%rsp) - fldl one(%rip) - flds -12(%rsp) // x : 1 - fxam - fnstsw - fld %st // x : x : 1 - sahf - jc 3f // in case x is NaN or ±Inf -4: fsub %st(2), %st // x-1 : x : 1 - fld %st // x-1 : x-1 : x : 1 - fabs // |x-1| : x-1 : x : 1 - fcompl limit(%rip) // x-1 : x : 1 - fnstsw // x-1 : x : 1 - andb $0x45, %ah - jz 2f - fstp %st(1) // x-1 : 1 - fyl2xp1 // log(x) - fstps -12(%rsp) - movss -12(%rsp),%xmm0 - ret - -2: fstp %st(0) // x : 1 - fyl2x // log(x) - fstps -12(%rsp) - movss -12(%rsp),%xmm0 - ret - -3: jp 4b // in case x is ±Inf - fstp %st(1) - fstp %st(1) - fstps -12(%rsp) - movss -12(%rsp),%xmm0 - ret -#else - fldl one - flds 4(%esp) // x : 1 - fxam - fnstsw - fld %st // x : x : 1 - sahf - jc 3f // in case x is NaN or ±Inf -4: fsub %st(2), %st // x-1 : x : 1 - fld %st // x-1 : x-1 : x : 1 - fabs // |x-1| : x-1 : x : 1 - fcompl limit // x-1 : x : 1 - fnstsw // x-1 : x : 1 - andb $0x45, %ah - jz 2f - fstp %st(1) // x-1 : 1 - fyl2xp1 // log(x) - ret - -2: fstp %st(0) // x : 1 - fyl2x // log(x) - ret - -3: jp 4b // in case x is ±Inf - fstp %st(1) - fstp %st(1) - ret -#endif diff --git a/lib/libc/musl/src/math/aarch64/fmax.c b/lib/libc/musl/src/math/aarch64/fmax.c @@ -1,7 +0,0 @@ -#include <math.h> - -double fmax(double x, double y) -{ - __asm__ ("fmaxnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y)); - return x; -} diff --git a/lib/libc/musl/src/math/aarch64/fmaxf.c b/lib/libc/musl/src/math/aarch64/fmaxf.c @@ -1,7 +0,0 @@ -#include <math.h> - -float fmaxf(float x, float y) -{ - __asm__ ("fmaxnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y)); - return x; -} diff --git a/lib/libc/musl/src/math/aarch64/fmin.c b/lib/libc/musl/src/math/aarch64/fmin.c @@ -1,7 +0,0 @@ -#include <math.h> - -double fmin(double x, double y) -{ - __asm__ ("fminnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y)); - return x; -} diff --git a/lib/libc/musl/src/math/aarch64/fminf.c b/lib/libc/musl/src/math/aarch64/fminf.c @@ -1,7 +0,0 @@ -#include <math.h> - -float fminf(float x, float y) -{ - __asm__ ("fminnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y)); - return x; -} diff --git a/lib/libc/musl/src/math/aarch64/sqrt.c b/lib/libc/musl/src/math/aarch64/sqrt.c @@ -1,7 +0,0 @@ -#include <math.h> - -double sqrt(double x) -{ - __asm__ ("fsqrt %d0, %d1" : "=w"(x) : "w"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/aarch64/sqrtf.c b/lib/libc/musl/src/math/aarch64/sqrtf.c @@ -1,7 +0,0 @@ -#include <math.h> - -float sqrtf(float x) -{ - __asm__ ("fsqrt %s0, %s1" : "=w"(x) : "w"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/arm/sqrt.c b/lib/libc/musl/src/math/arm/sqrt.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && (__ARM_FP&8) - -double sqrt(double x) -{ - __asm__ ("vsqrt.f64 %P0, %P1" : "=w"(x) : "w"(x)); - return x; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/arm/sqrtf.c b/lib/libc/musl/src/math/arm/sqrtf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM - -float sqrtf(float x) -{ - __asm__ ("vsqrt.f32 %0, %1" : "=t"(x) : "t"(x)); - return x; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/copysign.c b/lib/libc/musl/src/math/copysign.c @@ -1,8 +0,0 @@ -#include "libm.h" - -double copysign(double x, double y) { - union {double f; uint64_t i;} ux={x}, uy={y}; - ux.i &= -1ULL/2; - ux.i |= uy.i & 1ULL<<63; - return ux.f; -} diff --git a/lib/libc/musl/src/math/copysignf.c b/lib/libc/musl/src/math/copysignf.c @@ -1,10 +0,0 @@ -#include <math.h> -#include <stdint.h> - -float copysignf(float x, float y) -{ - union {float f; uint32_t i;} ux={x}, uy={y}; - ux.i &= 0x7fffffff; - ux.i |= uy.i & 0x80000000; - return ux.f; -} diff --git a/lib/libc/musl/src/math/copysignl.c b/lib/libc/musl/src/math/copysignl.c @@ -1,16 +0,0 @@ -#include "libm.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double copysignl(long double x, long double y) -{ - return copysign(x, y); -} -#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 -long double copysignl(long double x, long double y) -{ - union ldshape ux = {x}, uy = {y}; - ux.i.se &= 0x7fff; - ux.i.se |= uy.i.se & 0x8000; - return ux.f; -} -#endif diff --git a/lib/libc/musl/src/math/fmax.c b/lib/libc/musl/src/math/fmax.c @@ -1,13 +0,0 @@ -#include <math.h> - -double fmax(double x, double y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeros, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? y : x; - return x < y ? y : x; -} diff --git a/lib/libc/musl/src/math/fmaxf.c b/lib/libc/musl/src/math/fmaxf.c @@ -1,13 +0,0 @@ -#include <math.h> - -float fmaxf(float x, float y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeroes, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? y : x; - return x < y ? y : x; -} diff --git a/lib/libc/musl/src/math/fmaxl.c b/lib/libc/musl/src/math/fmaxl.c @@ -1,21 +0,0 @@ -#include <math.h> -#include <float.h> - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double fmaxl(long double x, long double y) -{ - return fmax(x, y); -} -#else -long double fmaxl(long double x, long double y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeros, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? y : x; - return x < y ? y : x; -} -#endif diff --git a/lib/libc/musl/src/math/fmin.c b/lib/libc/musl/src/math/fmin.c @@ -1,13 +0,0 @@ -#include <math.h> - -double fmin(double x, double y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeros, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? x : y; - return x < y ? x : y; -} diff --git a/lib/libc/musl/src/math/fminf.c b/lib/libc/musl/src/math/fminf.c @@ -1,13 +0,0 @@ -#include <math.h> - -float fminf(float x, float y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeros, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? x : y; - return x < y ? x : y; -} diff --git a/lib/libc/musl/src/math/fminl.c b/lib/libc/musl/src/math/fminl.c @@ -1,21 +0,0 @@ -#include <math.h> -#include <float.h> - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double fminl(long double x, long double y) -{ - return fmin(x, y); -} -#else -long double fminl(long double x, long double y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - /* handle signed zeros, see C99 Annex F.9.9.2 */ - if (signbit(x) != signbit(y)) - return signbit(x) ? x : y; - return x < y ? x : y; -} -#endif diff --git a/lib/libc/musl/src/math/i386/fmod.c b/lib/libc/musl/src/math/i386/fmod.c @@ -1,10 +0,0 @@ -#include <math.h> - -double fmod(double x, double y) -{ - unsigned short fpsr; - // fprem does not introduce excess precision into x - do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); - while (fpsr & 0x400); - return x; -} diff --git a/lib/libc/musl/src/math/i386/fmodf.c b/lib/libc/musl/src/math/i386/fmodf.c @@ -1,10 +0,0 @@ -#include <math.h> - -float fmodf(float x, float y) -{ - unsigned short fpsr; - // fprem does not introduce excess precision into x - do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); - while (fpsr & 0x400); - return x; -} diff --git a/lib/libc/musl/src/math/i386/fmodl.c b/lib/libc/musl/src/math/i386/fmodl.c @@ -1,9 +0,0 @@ -#include <math.h> - -long double fmodl(long double x, long double y) -{ - unsigned short fpsr; - do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); - while (fpsr & 0x400); - return x; -} diff --git a/lib/libc/musl/src/math/i386/log.s b/lib/libc/musl/src/math/i386/log.s @@ -1,9 +0,0 @@ -.global log -.type log,@function -log: - fldln2 - fldl 4(%esp) - fyl2x - fstpl 4(%esp) - fldl 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/log10.s b/lib/libc/musl/src/math/i386/log10.s @@ -1,9 +0,0 @@ -.global log10 -.type log10,@function -log10: - fldlg2 - fldl 4(%esp) - fyl2x - fstpl 4(%esp) - fldl 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/log10f.s b/lib/libc/musl/src/math/i386/log10f.s @@ -1,9 +0,0 @@ -.global log10f -.type log10f,@function -log10f: - fldlg2 - flds 4(%esp) - fyl2x - fstps 4(%esp) - flds 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/log2.s b/lib/libc/musl/src/math/i386/log2.s @@ -1,9 +0,0 @@ -.global log2 -.type log2,@function -log2: - fld1 - fldl 4(%esp) - fyl2x - fstpl 4(%esp) - fldl 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/log2f.s b/lib/libc/musl/src/math/i386/log2f.s @@ -1,9 +0,0 @@ -.global log2f -.type log2f,@function -log2f: - fld1 - flds 4(%esp) - fyl2x - fstps 4(%esp) - flds 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/logf.s b/lib/libc/musl/src/math/i386/logf.s @@ -1,9 +0,0 @@ -.global logf -.type logf,@function -logf: - fldln2 - flds 4(%esp) - fyl2x - fstps 4(%esp) - flds 4(%esp) - ret diff --git a/lib/libc/musl/src/math/i386/sqrt.c b/lib/libc/musl/src/math/i386/sqrt.c @@ -1,15 +0,0 @@ -#include "libm.h" - -double sqrt(double x) -{ - union ldshape ux; - unsigned fpsr; - __asm__ ("fsqrt; fnstsw %%ax": "=t"(ux.f), "=a"(fpsr) : "0"(x)); - if ((ux.i.m & 0x7ff) != 0x400) - return (double)ux.f; - /* Rounding to double would have encountered an exact halfway case. - Adjust mantissa downwards if fsqrt rounded up, else upwards. - (result of fsqrt could not have been exact) */ - ux.i.m ^= (fpsr & 0x200) + 0x300; - return (double)ux.f; -} diff --git a/lib/libc/musl/src/math/i386/sqrtf.c b/lib/libc/musl/src/math/i386/sqrtf.c @@ -1,12 +0,0 @@ -#include <math.h> - -float sqrtf(float x) -{ - long double t; - /* The long double result has sufficient precision so that - * second rounding to float still keeps the returned value - * correctly rounded, see Pierre Roux, "Innocuous Double - * Rounding of Basic Arithmetic Operations". */ - __asm__ ("fsqrt" : "=t"(t) : "0"(x)); - return (float)t; -} diff --git a/lib/libc/musl/src/math/i386/sqrtl.c b/lib/libc/musl/src/math/i386/sqrtl.c @@ -1,7 +0,0 @@ -#include <math.h> - -long double sqrtl(long double x) -{ - __asm__ ("fsqrt" : "+t"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/log2_data.c b/lib/libc/musl/src/math/log2_data.c @@ -1,201 +0,0 @@ -/* - * Data for log2. - * - * Copyright (c) 2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ - -#include "log2_data.h" - -#define N (1 << LOG2_TABLE_BITS) - -const struct log2_data __log2_data = { -// First coefficient: 0x1.71547652b82fe1777d0ffda0d24p0 -.invln2hi = 0x1.7154765200000p+0, -.invln2lo = 0x1.705fc2eefa200p-33, -.poly1 = { -// relative error: 0x1.2fad8188p-63 -// in -0x1.5b51p-5 0x1.6ab2p-5 --0x1.71547652b82fep-1, -0x1.ec709dc3a03f7p-2, --0x1.71547652b7c3fp-2, -0x1.2776c50f05be4p-2, --0x1.ec709dd768fe5p-3, -0x1.a61761ec4e736p-3, --0x1.7153fbc64a79bp-3, -0x1.484d154f01b4ap-3, --0x1.289e4a72c383cp-3, -0x1.0b32f285aee66p-3, -}, -.poly = { -// relative error: 0x1.a72c2bf8p-58 -// abs error: 0x1.67a552c8p-66 -// in -0x1.f45p-8 0x1.f45p-8 --0x1.71547652b8339p-1, -0x1.ec709dc3a04bep-2, --0x1.7154764702ffbp-2, -0x1.2776c50034c48p-2, --0x1.ec7b328ea92bcp-3, -0x1.a6225e117f92ep-3, -}, -/* Algorithm: - - x = 2^k z - log2(x) = k + log2(c) + log2(z/c) - log2(z/c) = poly(z/c - 1) - -where z is in [1.6p-1; 1.6p0] which is split into N subintervals and z falls -into the ith one, then table entries are computed as - - tab[i].invc = 1/c - tab[i].logc = (double)log2(c) - tab2[i].chi = (double)c - tab2[i].clo = (double)(c - (double)c) - -where c is near the center of the subinterval and is chosen by trying +-2^29 -floating point invc candidates around 1/center and selecting one for which - - 1) the rounding error in 0x1.8p10 + logc is 0, - 2) the rounding error in z - chi - clo is < 0x1p-64 and - 3) the rounding error in (double)log2(c) is minimized (< 0x1p-68). - -Note: 1) ensures that k + logc can be computed without rounding error, 2) -ensures that z/c - 1 can be computed as (z - chi - clo)*invc with close to a -single rounding error when there is no fast fma for z*invc - 1, 3) ensures -that logc + poly(z/c - 1) has small error, however near x == 1 when -|log2(x)| < 0x1p-4, this is not enough so that is special cased. */ -.tab = { -{0x1.724286bb1acf8p+0, -0x1.1095feecdb000p-1}, -{0x1.6e1f766d2cca1p+0, -0x1.08494bd76d000p-1}, -{0x1.6a13d0e30d48ap+0, -0x1.00143aee8f800p-1}, -{0x1.661ec32d06c85p+0, -0x1.efec5360b4000p-2}, -{0x1.623fa951198f8p+0, -0x1.dfdd91ab7e000p-2}, -{0x1.5e75ba4cf026cp+0, -0x1.cffae0cc79000p-2}, -{0x1.5ac055a214fb8p+0, -0x1.c043811fda000p-2}, -{0x1.571ed0f166e1ep+0, -0x1.b0b67323ae000p-2}, -{0x1.53909590bf835p+0, -0x1.a152f5a2db000p-2}, -{0x1.5014fed61adddp+0, -0x1.9217f5af86000p-2}, -{0x1.4cab88e487bd0p+0, -0x1.8304db0719000p-2}, -{0x1.49539b4334feep+0, -0x1.74189f9a9e000p-2}, -{0x1.460cbdfafd569p+0, -0x1.6552bb5199000p-2}, -{0x1.42d664ee4b953p+0, -0x1.56b23a29b1000p-2}, -{0x1.3fb01111dd8a6p+0, -0x1.483650f5fa000p-2}, -{0x1.3c995b70c5836p+0, -0x1.39de937f6a000p-2}, -{0x1.3991c4ab6fd4ap+0, -0x1.2baa1538d6000p-2}, -{0x1.3698e0ce099b5p+0, -0x1.1d98340ca4000p-2}, -{0x1.33ae48213e7b2p+0, -0x1.0fa853a40e000p-2}, -{0x1.30d191985bdb1p+0, -0x1.01d9c32e73000p-2}, -{0x1.2e025cab271d7p+0, -0x1.e857da2fa6000p-3}, -{0x1.2b404cf13cd82p+0, -0x1.cd3c8633d8000p-3}, -{0x1.288b02c7ccb50p+0, -0x1.b26034c14a000p-3}, -{0x1.25e2263944de5p+0, -0x1.97c1c2f4fe000p-3}, -{0x1.234563d8615b1p+0, -0x1.7d6023f800000p-3}, -{0x1.20b46e33eaf38p+0, -0x1.633a71a05e000p-3}, -{0x1.1e2eefdcda3ddp+0, -0x1.494f5e9570000p-3}, -{0x1.1bb4a580b3930p+0, -0x1.2f9e424e0a000p-3}, -{0x1.19453847f2200p+0, -0x1.162595afdc000p-3}, -{0x1.16e06c0d5d73cp+0, -0x1.f9c9a75bd8000p-4}, -{0x1.1485f47b7e4c2p+0, -0x1.c7b575bf9c000p-4}, -{0x1.12358ad0085d1p+0, -0x1.960c60ff48000p-4}, -{0x1.0fef00f532227p+0, -0x1.64ce247b60000p-4}, -{0x1.0db2077d03a8fp+0, -0x1.33f78b2014000p-4}, -{0x1.0b7e6d65980d9p+0, -0x1.0387d1a42c000p-4}, -{0x1.0953efe7b408dp+0, -0x1.a6f9208b50000p-5}, -{0x1.07325cac53b83p+0, -0x1.47a954f770000p-5}, -{0x1.05197e40d1b5cp+0, -0x1.d23a8c50c0000p-6}, -{0x1.03091c1208ea2p+0, -0x1.16a2629780000p-6}, -{0x1.0101025b37e21p+0, -0x1.720f8d8e80000p-8}, -{0x1.fc07ef9caa76bp-1, 0x1.6fe53b1500000p-7}, -{0x1.f4465d3f6f184p-1, 0x1.11ccce10f8000p-5}, -{0x1.ecc079f84107fp-1, 0x1.c4dfc8c8b8000p-5}, -{0x1.e573a99975ae8p-1, 0x1.3aa321e574000p-4}, -{0x1.de5d6f0bd3de6p-1, 0x1.918a0d08b8000p-4}, -{0x1.d77b681ff38b3p-1, 0x1.e72e9da044000p-4}, -{0x1.d0cb5724de943p-1, 0x1.1dcd2507f6000p-3}, -{0x1.ca4b2dc0e7563p-1, 0x1.476ab03dea000p-3}, -{0x1.c3f8ee8d6cb51p-1, 0x1.7074377e22000p-3}, -{0x1.bdd2b4f020c4cp-1, 0x1.98ede8ba94000p-3}, -{0x1.b7d6c006015cap-1, 0x1.c0db86ad2e000p-3}, -{0x1.b20366e2e338fp-1, 0x1.e840aafcee000p-3}, -{0x1.ac57026295039p-1, 0x1.0790ab4678000p-2}, -{0x1.a6d01bc2731ddp-1, 0x1.1ac056801c000p-2}, -{0x1.a16d3bc3ff18bp-1, 0x1.2db11d4fee000p-2}, -{0x1.9c2d14967feadp-1, 0x1.406464ec58000p-2}, -{0x1.970e4f47c9902p-1, 0x1.52dbe093af000p-2}, -{0x1.920fb3982bcf2p-1, 0x1.651902050d000p-2}, -{0x1.8d30187f759f1p-1, 0x1.771d2cdeaf000p-2}, -{0x1.886e5ebb9f66dp-1, 0x1.88e9c857d9000p-2}, -{0x1.83c97b658b994p-1, 0x1.9a80155e16000p-2}, -{0x1.7f405ffc61022p-1, 0x1.abe186ed3d000p-2}, -{0x1.7ad22181415cap-1, 0x1.bd0f2aea0e000p-2}, -{0x1.767dcf99eff8cp-1, 0x1.ce0a43dbf4000p-2}, -}, -#if !__FP_FAST_FMA -.tab2 = { -{0x1.6200012b90a8ep-1, 0x1.904ab0644b605p-55}, -{0x1.66000045734a6p-1, 0x1.1ff9bea62f7a9p-57}, -{0x1.69fffc325f2c5p-1, 0x1.27ecfcb3c90bap-55}, -{0x1.6e00038b95a04p-1, 0x1.8ff8856739326p-55}, -{0x1.71fffe09994e3p-1, 0x1.afd40275f82b1p-55}, -{0x1.7600015590e1p-1, -0x1.2fd75b4238341p-56}, -{0x1.7a00012655bd5p-1, 0x1.808e67c242b76p-56}, -{0x1.7e0003259e9a6p-1, -0x1.208e426f622b7p-57}, -{0x1.81fffedb4b2d2p-1, -0x1.402461ea5c92fp-55}, -{0x1.860002dfafcc3p-1, 0x1.df7f4a2f29a1fp-57}, -{0x1.89ffff78c6b5p-1, -0x1.e0453094995fdp-55}, -{0x1.8e00039671566p-1, -0x1.a04f3bec77b45p-55}, -{0x1.91fffe2bf1745p-1, -0x1.7fa34400e203cp-56}, -{0x1.95fffcc5c9fd1p-1, -0x1.6ff8005a0695dp-56}, -{0x1.9a0003bba4767p-1, 0x1.0f8c4c4ec7e03p-56}, -{0x1.9dfffe7b92da5p-1, 0x1.e7fd9478c4602p-55}, -{0x1.a1fffd72efdafp-1, -0x1.a0c554dcdae7ep-57}, -{0x1.a5fffde04ff95p-1, 0x1.67da98ce9b26bp-55}, -{0x1.a9fffca5e8d2bp-1, -0x1.284c9b54c13dep-55}, -{0x1.adfffddad03eap-1, 0x1.812c8ea602e3cp-58}, -{0x1.b1ffff10d3d4dp-1, -0x1.efaddad27789cp-55}, -{0x1.b5fffce21165ap-1, 0x1.3cb1719c61237p-58}, -{0x1.b9fffd950e674p-1, 0x1.3f7d94194cep-56}, -{0x1.be000139ca8afp-1, 0x1.50ac4215d9bcp-56}, -{0x1.c20005b46df99p-1, 0x1.beea653e9c1c9p-57}, -{0x1.c600040b9f7aep-1, -0x1.c079f274a70d6p-56}, -{0x1.ca0006255fd8ap-1, -0x1.a0b4076e84c1fp-56}, -{0x1.cdfffd94c095dp-1, 0x1.8f933f99ab5d7p-55}, -{0x1.d1ffff975d6cfp-1, -0x1.82c08665fe1bep-58}, -{0x1.d5fffa2561c93p-1, -0x1.b04289bd295f3p-56}, -{0x1.d9fff9d228b0cp-1, 0x1.70251340fa236p-55}, -{0x1.de00065bc7e16p-1, -0x1.5011e16a4d80cp-56}, -{0x1.e200002f64791p-1, 0x1.9802f09ef62ep-55}, -{0x1.e600057d7a6d8p-1, -0x1.e0b75580cf7fap-56}, -{0x1.ea00027edc00cp-1, -0x1.c848309459811p-55}, -{0x1.ee0006cf5cb7cp-1, -0x1.f8027951576f4p-55}, -{0x1.f2000782b7dccp-1, -0x1.f81d97274538fp-55}, -{0x1.f6000260c450ap-1, -0x1.071002727ffdcp-59}, -{0x1.f9fffe88cd533p-1, -0x1.81bdce1fda8bp-58}, -{0x1.fdfffd50f8689p-1, 0x1.7f91acb918e6ep-55}, -{0x1.0200004292367p+0, 0x1.b7ff365324681p-54}, -{0x1.05fffe3e3d668p+0, 0x1.6fa08ddae957bp-55}, -{0x1.0a0000a85a757p+0, -0x1.7e2de80d3fb91p-58}, -{0x1.0e0001a5f3fccp+0, -0x1.1823305c5f014p-54}, -{0x1.11ffff8afbaf5p+0, -0x1.bfabb6680bac2p-55}, -{0x1.15fffe54d91adp+0, -0x1.d7f121737e7efp-54}, -{0x1.1a00011ac36e1p+0, 0x1.c000a0516f5ffp-54}, -{0x1.1e00019c84248p+0, -0x1.082fbe4da5dap-54}, -{0x1.220000ffe5e6ep+0, -0x1.8fdd04c9cfb43p-55}, -{0x1.26000269fd891p+0, 0x1.cfe2a7994d182p-55}, -{0x1.2a00029a6e6dap+0, -0x1.00273715e8bc5p-56}, -{0x1.2dfffe0293e39p+0, 0x1.b7c39dab2a6f9p-54}, -{0x1.31ffff7dcf082p+0, 0x1.df1336edc5254p-56}, -{0x1.35ffff05a8b6p+0, -0x1.e03564ccd31ebp-54}, -{0x1.3a0002e0eaeccp+0, 0x1.5f0e74bd3a477p-56}, -{0x1.3e000043bb236p+0, 0x1.c7dcb149d8833p-54}, -{0x1.4200002d187ffp+0, 0x1.e08afcf2d3d28p-56}, -{0x1.460000d387cb1p+0, 0x1.20837856599a6p-55}, -{0x1.4a00004569f89p+0, -0x1.9fa5c904fbcd2p-55}, -{0x1.4e000043543f3p+0, -0x1.81125ed175329p-56}, -{0x1.51fffcc027f0fp+0, 0x1.883d8847754dcp-54}, -{0x1.55ffffd87b36fp+0, -0x1.709e731d02807p-55}, -{0x1.59ffff21df7bap+0, 0x1.7f79f68727b02p-55}, -{0x1.5dfffebfc3481p+0, -0x1.180902e30e93ep-54}, -}, -#endif -}; diff --git a/lib/libc/musl/src/math/log2_data.h b/lib/libc/musl/src/math/log2_data.h @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ -#ifndef _LOG2_DATA_H -#define _LOG2_DATA_H - -#include <features.h> - -#define LOG2_TABLE_BITS 6 -#define LOG2_POLY_ORDER 7 -#define LOG2_POLY1_ORDER 11 -extern hidden const struct log2_data { - double invln2hi; - double invln2lo; - double poly[LOG2_POLY_ORDER - 1]; - double poly1[LOG2_POLY1_ORDER - 1]; - struct { - double invc, logc; - } tab[1 << LOG2_TABLE_BITS]; -#if !__FP_FAST_FMA - struct { - double chi, clo; - } tab2[1 << LOG2_TABLE_BITS]; -#endif -} __log2_data; - -#endif diff --git a/lib/libc/musl/src/math/log2f_data.c b/lib/libc/musl/src/math/log2f_data.c @@ -1,33 +0,0 @@ -/* - * Data definition for log2f. - * - * Copyright (c) 2017-2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ - -#include "log2f_data.h" - -const struct log2f_data __log2f_data = { - .tab = { - { 0x1.661ec79f8f3bep+0, -0x1.efec65b963019p-2 }, - { 0x1.571ed4aaf883dp+0, -0x1.b0b6832d4fca4p-2 }, - { 0x1.49539f0f010bp+0, -0x1.7418b0a1fb77bp-2 }, - { 0x1.3c995b0b80385p+0, -0x1.39de91a6dcf7bp-2 }, - { 0x1.30d190c8864a5p+0, -0x1.01d9bf3f2b631p-2 }, - { 0x1.25e227b0b8eap+0, -0x1.97c1d1b3b7afp-3 }, - { 0x1.1bb4a4a1a343fp+0, -0x1.2f9e393af3c9fp-3 }, - { 0x1.12358f08ae5bap+0, -0x1.960cbbf788d5cp-4 }, - { 0x1.0953f419900a7p+0, -0x1.a6f9db6475fcep-5 }, - { 0x1p+0, 0x0p+0 }, - { 0x1.e608cfd9a47acp-1, 0x1.338ca9f24f53dp-4 }, - { 0x1.ca4b31f026aap-1, 0x1.476a9543891bap-3 }, - { 0x1.b2036576afce6p-1, 0x1.e840b4ac4e4d2p-3 }, - { 0x1.9c2d163a1aa2dp-1, 0x1.40645f0c6651cp-2 }, - { 0x1.886e6037841edp-1, 0x1.88e9c2c1b9ff8p-2 }, - { 0x1.767dcf5534862p-1, 0x1.ce0a44eb17bccp-2 }, - }, - .poly = { - -0x1.712b6f70a7e4dp-2, 0x1.ecabf496832ep-2, -0x1.715479ffae3dep-1, - 0x1.715475f35c8b8p0, - } -}; diff --git a/lib/libc/musl/src/math/log2f_data.h b/lib/libc/musl/src/math/log2f_data.h @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2017-2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ -#ifndef _LOG2F_DATA_H -#define _LOG2F_DATA_H - -#include <features.h> - -#define LOG2F_TABLE_BITS 4 -#define LOG2F_POLY_ORDER 4 -extern hidden const struct log2f_data { - struct { - double invc, logc; - } tab[1 << LOG2F_TABLE_BITS]; - double poly[LOG2F_POLY_ORDER]; -} __log2f_data; - -#endif diff --git a/lib/libc/musl/src/math/log_data.c b/lib/libc/musl/src/math/log_data.c @@ -1,328 +0,0 @@ -/* - * Data for log. - * - * Copyright (c) 2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ - -#include "log_data.h" - -#define N (1 << LOG_TABLE_BITS) - -const struct log_data __log_data = { -.ln2hi = 0x1.62e42fefa3800p-1, -.ln2lo = 0x1.ef35793c76730p-45, -.poly1 = { -// relative error: 0x1.c04d76cp-63 -// in -0x1p-4 0x1.09p-4 (|log(1+x)| > 0x1p-4 outside the interval) --0x1p-1, -0x1.5555555555577p-2, --0x1.ffffffffffdcbp-3, -0x1.999999995dd0cp-3, --0x1.55555556745a7p-3, -0x1.24924a344de3p-3, --0x1.fffffa4423d65p-4, -0x1.c7184282ad6cap-4, --0x1.999eb43b068ffp-4, -0x1.78182f7afd085p-4, --0x1.5521375d145cdp-4, -}, -.poly = { -// relative error: 0x1.926199e8p-56 -// abs error: 0x1.882ff33p-65 -// in -0x1.fp-9 0x1.fp-9 --0x1.0000000000001p-1, -0x1.555555551305bp-2, --0x1.fffffffeb459p-3, -0x1.999b324f10111p-3, --0x1.55575e506c89fp-3, -}, -/* Algorithm: - - x = 2^k z - log(x) = k ln2 + log(c) + log(z/c) - log(z/c) = poly(z/c - 1) - -where z is in [1.6p-1; 1.6p0] which is split into N subintervals and z falls -into the ith one, then table entries are computed as - - tab[i].invc = 1/c - tab[i].logc = (double)log(c) - tab2[i].chi = (double)c - tab2[i].clo = (double)(c - (double)c) - -where c is near the center of the subinterval and is chosen by trying +-2^29 -floating point invc candidates around 1/center and selecting one for which - - 1) the rounding error in 0x1.8p9 + logc is 0, - 2) the rounding error in z - chi - clo is < 0x1p-66 and - 3) the rounding error in (double)log(c) is minimized (< 0x1p-66). - -Note: 1) ensures that k*ln2hi + logc can be computed without rounding error, -2) ensures that z/c - 1 can be computed as (z - chi - clo)*invc with close to -a single rounding error when there is no fast fma for z*invc - 1, 3) ensures -that logc + poly(z/c - 1) has small error, however near x == 1 when -|log(x)| < 0x1p-4, this is not enough so that is special cased. */ -.tab = { -{0x1.734f0c3e0de9fp+0, -0x1.7cc7f79e69000p-2}, -{0x1.713786a2ce91fp+0, -0x1.76feec20d0000p-2}, -{0x1.6f26008fab5a0p+0, -0x1.713e31351e000p-2}, -{0x1.6d1a61f138c7dp+0, -0x1.6b85b38287800p-2}, -{0x1.6b1490bc5b4d1p+0, -0x1.65d5590807800p-2}, -{0x1.69147332f0cbap+0, -0x1.602d076180000p-2}, -{0x1.6719f18224223p+0, -0x1.5a8ca86909000p-2}, -{0x1.6524f99a51ed9p+0, -0x1.54f4356035000p-2}, -{0x1.63356aa8f24c4p+0, -0x1.4f637c36b4000p-2}, -{0x1.614b36b9ddc14p+0, -0x1.49da7fda85000p-2}, -{0x1.5f66452c65c4cp+0, -0x1.445923989a800p-2}, -{0x1.5d867b5912c4fp+0, -0x1.3edf439b0b800p-2}, -{0x1.5babccb5b90dep+0, -0x1.396ce448f7000p-2}, -{0x1.59d61f2d91a78p+0, -0x1.3401e17bda000p-2}, -{0x1.5805612465687p+0, -0x1.2e9e2ef468000p-2}, -{0x1.56397cee76bd3p+0, -0x1.2941b3830e000p-2}, -{0x1.54725e2a77f93p+0, -0x1.23ec58cda8800p-2}, -{0x1.52aff42064583p+0, -0x1.1e9e129279000p-2}, -{0x1.50f22dbb2bddfp+0, -0x1.1956d2b48f800p-2}, -{0x1.4f38f4734ded7p+0, -0x1.141679ab9f800p-2}, -{0x1.4d843cfde2840p+0, -0x1.0edd094ef9800p-2}, -{0x1.4bd3ec078a3c8p+0, -0x1.09aa518db1000p-2}, -{0x1.4a27fc3e0258ap+0, -0x1.047e65263b800p-2}, -{0x1.4880524d48434p+0, -0x1.feb224586f000p-3}, -{0x1.46dce1b192d0bp+0, -0x1.f474a7517b000p-3}, -{0x1.453d9d3391854p+0, -0x1.ea4443d103000p-3}, -{0x1.43a2744b4845ap+0, -0x1.e020d44e9b000p-3}, -{0x1.420b54115f8fbp+0, -0x1.d60a22977f000p-3}, -{0x1.40782da3ef4b1p+0, -0x1.cc00104959000p-3}, -{0x1.3ee8f5d57fe8fp+0, -0x1.c202956891000p-3}, -{0x1.3d5d9a00b4ce9p+0, -0x1.b81178d811000p-3}, -{0x1.3bd60c010c12bp+0, -0x1.ae2c9ccd3d000p-3}, -{0x1.3a5242b75dab8p+0, -0x1.a45402e129000p-3}, -{0x1.38d22cd9fd002p+0, -0x1.9a877681df000p-3}, -{0x1.3755bc5847a1cp+0, -0x1.90c6d69483000p-3}, -{0x1.35dce49ad36e2p+0, -0x1.87120a645c000p-3}, -{0x1.34679984dd440p+0, -0x1.7d68fb4143000p-3}, -{0x1.32f5cceffcb24p+0, -0x1.73cb83c627000p-3}, -{0x1.3187775a10d49p+0, -0x1.6a39a9b376000p-3}, -{0x1.301c8373e3990p+0, -0x1.60b3154b7a000p-3}, -{0x1.2eb4ebb95f841p+0, -0x1.5737d76243000p-3}, -{0x1.2d50a0219a9d1p+0, -0x1.4dc7b8fc23000p-3}, -{0x1.2bef9a8b7fd2ap+0, -0x1.4462c51d20000p-3}, -{0x1.2a91c7a0c1babp+0, -0x1.3b08abc830000p-3}, -{0x1.293726014b530p+0, -0x1.31b996b490000p-3}, -{0x1.27dfa5757a1f5p+0, -0x1.2875490a44000p-3}, -{0x1.268b39b1d3bbfp+0, -0x1.1f3b9f879a000p-3}, -{0x1.2539d838ff5bdp+0, -0x1.160c8252ca000p-3}, -{0x1.23eb7aac9083bp+0, -0x1.0ce7f57f72000p-3}, -{0x1.22a012ba940b6p+0, -0x1.03cdc49fea000p-3}, -{0x1.2157996cc4132p+0, -0x1.f57bdbc4b8000p-4}, -{0x1.201201dd2fc9bp+0, -0x1.e370896404000p-4}, -{0x1.1ecf4494d480bp+0, -0x1.d17983ef94000p-4}, -{0x1.1d8f5528f6569p+0, -0x1.bf9674ed8a000p-4}, -{0x1.1c52311577e7cp+0, -0x1.adc79202f6000p-4}, -{0x1.1b17c74cb26e9p+0, -0x1.9c0c3e7288000p-4}, -{0x1.19e010c2c1ab6p+0, -0x1.8a646b372c000p-4}, -{0x1.18ab07bb670bdp+0, -0x1.78d01b3ac0000p-4}, -{0x1.1778a25efbcb6p+0, -0x1.674f145380000p-4}, -{0x1.1648d354c31dap+0, -0x1.55e0e6d878000p-4}, -{0x1.151b990275fddp+0, -0x1.4485cdea1e000p-4}, -{0x1.13f0ea432d24cp+0, -0x1.333d94d6aa000p-4}, -{0x1.12c8b7210f9dap+0, -0x1.22079f8c56000p-4}, -{0x1.11a3028ecb531p+0, -0x1.10e4698622000p-4}, -{0x1.107fbda8434afp+0, -0x1.ffa6c6ad20000p-5}, -{0x1.0f5ee0f4e6bb3p+0, -0x1.dda8d4a774000p-5}, -{0x1.0e4065d2a9fcep+0, -0x1.bbcece4850000p-5}, -{0x1.0d244632ca521p+0, -0x1.9a1894012c000p-5}, -{0x1.0c0a77ce2981ap+0, -0x1.788583302c000p-5}, -{0x1.0af2f83c636d1p+0, -0x1.5715e67d68000p-5}, -{0x1.09ddb98a01339p+0, -0x1.35c8a49658000p-5}, -{0x1.08cabaf52e7dfp+0, -0x1.149e364154000p-5}, -{0x1.07b9f2f4e28fbp+0, -0x1.e72c082eb8000p-6}, -{0x1.06ab58c358f19p+0, -0x1.a55f152528000p-6}, -{0x1.059eea5ecf92cp+0, -0x1.63d62cf818000p-6}, -{0x1.04949cdd12c90p+0, -0x1.228fb8caa0000p-6}, -{0x1.038c6c6f0ada9p+0, -0x1.c317b20f90000p-7}, -{0x1.02865137932a9p+0, -0x1.419355daa0000p-7}, -{0x1.0182427ea7348p+0, -0x1.81203c2ec0000p-8}, -{0x1.008040614b195p+0, -0x1.0040979240000p-9}, -{0x1.fe01ff726fa1ap-1, 0x1.feff384900000p-9}, -{0x1.fa11cc261ea74p-1, 0x1.7dc41353d0000p-7}, -{0x1.f6310b081992ep-1, 0x1.3cea3c4c28000p-6}, -{0x1.f25f63ceeadcdp-1, 0x1.b9fc114890000p-6}, -{0x1.ee9c8039113e7p-1, 0x1.1b0d8ce110000p-5}, -{0x1.eae8078cbb1abp-1, 0x1.58a5bd001c000p-5}, -{0x1.e741aa29d0c9bp-1, 0x1.95c8340d88000p-5}, -{0x1.e3a91830a99b5p-1, 0x1.d276aef578000p-5}, -{0x1.e01e009609a56p-1, 0x1.07598e598c000p-4}, -{0x1.dca01e577bb98p-1, 0x1.253f5e30d2000p-4}, -{0x1.d92f20b7c9103p-1, 0x1.42edd8b380000p-4}, -{0x1.d5cac66fb5ccep-1, 0x1.606598757c000p-4}, -{0x1.d272caa5ede9dp-1, 0x1.7da76356a0000p-4}, -{0x1.cf26e3e6b2ccdp-1, 0x1.9ab434e1c6000p-4}, -{0x1.cbe6da2a77902p-1, 0x1.b78c7bb0d6000p-4}, -{0x1.c8b266d37086dp-1, 0x1.d431332e72000p-4}, -{0x1.c5894bd5d5804p-1, 0x1.f0a3171de6000p-4}, -{0x1.c26b533bb9f8cp-1, 0x1.067152b914000p-3}, -{0x1.bf583eeece73fp-1, 0x1.147858292b000p-3}, -{0x1.bc4fd75db96c1p-1, 0x1.2266ecdca3000p-3}, -{0x1.b951e0c864a28p-1, 0x1.303d7a6c55000p-3}, -{0x1.b65e2c5ef3e2cp-1, 0x1.3dfc33c331000p-3}, -{0x1.b374867c9888bp-1, 0x1.4ba366b7a8000p-3}, -{0x1.b094b211d304ap-1, 0x1.5933928d1f000p-3}, -{0x1.adbe885f2ef7ep-1, 0x1.66acd2418f000p-3}, -{0x1.aaf1d31603da2p-1, 0x1.740f8ec669000p-3}, -{0x1.a82e63fd358a7p-1, 0x1.815c0f51af000p-3}, -{0x1.a5740ef09738bp-1, 0x1.8e92954f68000p-3}, -{0x1.a2c2a90ab4b27p-1, 0x1.9bb3602f84000p-3}, -{0x1.a01a01393f2d1p-1, 0x1.a8bed1c2c0000p-3}, -{0x1.9d79f24db3c1bp-1, 0x1.b5b515c01d000p-3}, -{0x1.9ae2505c7b190p-1, 0x1.c2967ccbcc000p-3}, -{0x1.9852ef297ce2fp-1, 0x1.cf635d5486000p-3}, -{0x1.95cbaeea44b75p-1, 0x1.dc1bd3446c000p-3}, -{0x1.934c69de74838p-1, 0x1.e8c01b8cfe000p-3}, -{0x1.90d4f2f6752e6p-1, 0x1.f5509c0179000p-3}, -{0x1.8e6528effd79dp-1, 0x1.00e6c121fb800p-2}, -{0x1.8bfce9fcc007cp-1, 0x1.071b80e93d000p-2}, -{0x1.899c0dabec30ep-1, 0x1.0d46b9e867000p-2}, -{0x1.87427aa2317fbp-1, 0x1.13687334bd000p-2}, -{0x1.84f00acb39a08p-1, 0x1.1980d67234800p-2}, -{0x1.82a49e8653e55p-1, 0x1.1f8ffe0cc8000p-2}, -{0x1.8060195f40260p-1, 0x1.2595fd7636800p-2}, -{0x1.7e22563e0a329p-1, 0x1.2b9300914a800p-2}, -{0x1.7beb377dcb5adp-1, 0x1.3187210436000p-2}, -{0x1.79baa679725c2p-1, 0x1.377266dec1800p-2}, -{0x1.77907f2170657p-1, 0x1.3d54ffbaf3000p-2}, -{0x1.756cadbd6130cp-1, 0x1.432eee32fe000p-2}, -}, -#if !__FP_FAST_FMA -.tab2 = { -{0x1.61000014fb66bp-1, 0x1.e026c91425b3cp-56}, -{0x1.63000034db495p-1, 0x1.dbfea48005d41p-55}, -{0x1.650000d94d478p-1, 0x1.e7fa786d6a5b7p-55}, -{0x1.67000074e6fadp-1, 0x1.1fcea6b54254cp-57}, -{0x1.68ffffedf0faep-1, -0x1.c7e274c590efdp-56}, -{0x1.6b0000763c5bcp-1, -0x1.ac16848dcda01p-55}, -{0x1.6d0001e5cc1f6p-1, 0x1.33f1c9d499311p-55}, -{0x1.6efffeb05f63ep-1, -0x1.e80041ae22d53p-56}, -{0x1.710000e86978p-1, 0x1.bff6671097952p-56}, -{0x1.72ffffc67e912p-1, 0x1.c00e226bd8724p-55}, -{0x1.74fffdf81116ap-1, -0x1.e02916ef101d2p-57}, -{0x1.770000f679c9p-1, -0x1.7fc71cd549c74p-57}, -{0x1.78ffffa7ec835p-1, 0x1.1bec19ef50483p-55}, -{0x1.7affffe20c2e6p-1, -0x1.07e1729cc6465p-56}, -{0x1.7cfffed3fc9p-1, -0x1.08072087b8b1cp-55}, -{0x1.7efffe9261a76p-1, 0x1.dc0286d9df9aep-55}, -{0x1.81000049ca3e8p-1, 0x1.97fd251e54c33p-55}, -{0x1.8300017932c8fp-1, -0x1.afee9b630f381p-55}, -{0x1.850000633739cp-1, 0x1.9bfbf6b6535bcp-55}, -{0x1.87000204289c6p-1, -0x1.bbf65f3117b75p-55}, -{0x1.88fffebf57904p-1, -0x1.9006ea23dcb57p-55}, -{0x1.8b00022bc04dfp-1, -0x1.d00df38e04b0ap-56}, -{0x1.8cfffe50c1b8ap-1, -0x1.8007146ff9f05p-55}, -{0x1.8effffc918e43p-1, 0x1.3817bd07a7038p-55}, -{0x1.910001efa5fc7p-1, 0x1.93e9176dfb403p-55}, -{0x1.9300013467bb9p-1, 0x1.f804e4b980276p-56}, -{0x1.94fffe6ee076fp-1, -0x1.f7ef0d9ff622ep-55}, -{0x1.96fffde3c12d1p-1, -0x1.082aa962638bap-56}, -{0x1.98ffff4458a0dp-1, -0x1.7801b9164a8efp-55}, -{0x1.9afffdd982e3ep-1, -0x1.740e08a5a9337p-55}, -{0x1.9cfffed49fb66p-1, 0x1.fce08c19bep-60}, -{0x1.9f00020f19c51p-1, -0x1.a3faa27885b0ap-55}, -{0x1.a10001145b006p-1, 0x1.4ff489958da56p-56}, -{0x1.a300007bbf6fap-1, 0x1.cbeab8a2b6d18p-55}, -{0x1.a500010971d79p-1, 0x1.8fecadd78793p-55}, -{0x1.a70001df52e48p-1, -0x1.f41763dd8abdbp-55}, -{0x1.a90001c593352p-1, -0x1.ebf0284c27612p-55}, -{0x1.ab0002a4f3e4bp-1, -0x1.9fd043cff3f5fp-57}, -{0x1.acfffd7ae1ed1p-1, -0x1.23ee7129070b4p-55}, -{0x1.aefffee510478p-1, 0x1.a063ee00edea3p-57}, -{0x1.b0fffdb650d5bp-1, 0x1.a06c8381f0ab9p-58}, -{0x1.b2ffffeaaca57p-1, -0x1.9011e74233c1dp-56}, -{0x1.b4fffd995badcp-1, -0x1.9ff1068862a9fp-56}, -{0x1.b7000249e659cp-1, 0x1.aff45d0864f3ep-55}, -{0x1.b8ffff987164p-1, 0x1.cfe7796c2c3f9p-56}, -{0x1.bafffd204cb4fp-1, -0x1.3ff27eef22bc4p-57}, -{0x1.bcfffd2415c45p-1, -0x1.cffb7ee3bea21p-57}, -{0x1.beffff86309dfp-1, -0x1.14103972e0b5cp-55}, -{0x1.c0fffe1b57653p-1, 0x1.bc16494b76a19p-55}, -{0x1.c2ffff1fa57e3p-1, -0x1.4feef8d30c6edp-57}, -{0x1.c4fffdcbfe424p-1, -0x1.43f68bcec4775p-55}, -{0x1.c6fffed54b9f7p-1, 0x1.47ea3f053e0ecp-55}, -{0x1.c8fffeb998fd5p-1, 0x1.383068df992f1p-56}, -{0x1.cb0002125219ap-1, -0x1.8fd8e64180e04p-57}, -{0x1.ccfffdd94469cp-1, 0x1.e7ebe1cc7ea72p-55}, -{0x1.cefffeafdc476p-1, 0x1.ebe39ad9f88fep-55}, -{0x1.d1000169af82bp-1, 0x1.57d91a8b95a71p-56}, -{0x1.d30000d0ff71dp-1, 0x1.9c1906970c7dap-55}, -{0x1.d4fffea790fc4p-1, -0x1.80e37c558fe0cp-58}, -{0x1.d70002edc87e5p-1, -0x1.f80d64dc10f44p-56}, -{0x1.d900021dc82aap-1, -0x1.47c8f94fd5c5cp-56}, -{0x1.dafffd86b0283p-1, 0x1.c7f1dc521617ep-55}, -{0x1.dd000296c4739p-1, 0x1.8019eb2ffb153p-55}, -{0x1.defffe54490f5p-1, 0x1.e00d2c652cc89p-57}, -{0x1.e0fffcdabf694p-1, -0x1.f8340202d69d2p-56}, -{0x1.e2fffdb52c8ddp-1, 0x1.b00c1ca1b0864p-56}, -{0x1.e4ffff24216efp-1, 0x1.2ffa8b094ab51p-56}, -{0x1.e6fffe88a5e11p-1, -0x1.7f673b1efbe59p-58}, -{0x1.e9000119eff0dp-1, -0x1.4808d5e0bc801p-55}, -{0x1.eafffdfa51744p-1, 0x1.80006d54320b5p-56}, -{0x1.ed0001a127fa1p-1, -0x1.002f860565c92p-58}, -{0x1.ef00007babcc4p-1, -0x1.540445d35e611p-55}, -{0x1.f0ffff57a8d02p-1, -0x1.ffb3139ef9105p-59}, -{0x1.f30001ee58ac7p-1, 0x1.a81acf2731155p-55}, -{0x1.f4ffff5823494p-1, 0x1.a3f41d4d7c743p-55}, -{0x1.f6ffffca94c6bp-1, -0x1.202f41c987875p-57}, -{0x1.f8fffe1f9c441p-1, 0x1.77dd1f477e74bp-56}, -{0x1.fafffd2e0e37ep-1, -0x1.f01199a7ca331p-57}, -{0x1.fd0001c77e49ep-1, 0x1.181ee4bceacb1p-56}, -{0x1.feffff7e0c331p-1, -0x1.e05370170875ap-57}, -{0x1.00ffff465606ep+0, -0x1.a7ead491c0adap-55}, -{0x1.02ffff3867a58p+0, -0x1.77f69c3fcb2ep-54}, -{0x1.04ffffdfc0d17p+0, 0x1.7bffe34cb945bp-54}, -{0x1.0700003cd4d82p+0, 0x1.20083c0e456cbp-55}, -{0x1.08ffff9f2cbe8p+0, -0x1.dffdfbe37751ap-57}, -{0x1.0b000010cda65p+0, -0x1.13f7faee626ebp-54}, -{0x1.0d00001a4d338p+0, 0x1.07dfa79489ff7p-55}, -{0x1.0effffadafdfdp+0, -0x1.7040570d66bcp-56}, -{0x1.110000bbafd96p+0, 0x1.e80d4846d0b62p-55}, -{0x1.12ffffae5f45dp+0, 0x1.dbffa64fd36efp-54}, -{0x1.150000dd59ad9p+0, 0x1.a0077701250aep-54}, -{0x1.170000f21559ap+0, 0x1.dfdf9e2e3deeep-55}, -{0x1.18ffffc275426p+0, 0x1.10030dc3b7273p-54}, -{0x1.1b000123d3c59p+0, 0x1.97f7980030188p-54}, -{0x1.1cffff8299eb7p+0, -0x1.5f932ab9f8c67p-57}, -{0x1.1effff48ad4p+0, 0x1.37fbf9da75bebp-54}, -{0x1.210000c8b86a4p+0, 0x1.f806b91fd5b22p-54}, -{0x1.2300003854303p+0, 0x1.3ffc2eb9fbf33p-54}, -{0x1.24fffffbcf684p+0, 0x1.601e77e2e2e72p-56}, -{0x1.26ffff52921d9p+0, 0x1.ffcbb767f0c61p-56}, -{0x1.2900014933a3cp+0, -0x1.202ca3c02412bp-56}, -{0x1.2b00014556313p+0, -0x1.2808233f21f02p-54}, -{0x1.2cfffebfe523bp+0, -0x1.8ff7e384fdcf2p-55}, -{0x1.2f0000bb8ad96p+0, -0x1.5ff51503041c5p-55}, -{0x1.30ffffb7ae2afp+0, -0x1.10071885e289dp-55}, -{0x1.32ffffeac5f7fp+0, -0x1.1ff5d3fb7b715p-54}, -{0x1.350000ca66756p+0, 0x1.57f82228b82bdp-54}, -{0x1.3700011fbf721p+0, 0x1.000bac40dd5ccp-55}, -{0x1.38ffff9592fb9p+0, -0x1.43f9d2db2a751p-54}, -{0x1.3b00004ddd242p+0, 0x1.57f6b707638e1p-55}, -{0x1.3cffff5b2c957p+0, 0x1.a023a10bf1231p-56}, -{0x1.3efffeab0b418p+0, 0x1.87f6d66b152bp-54}, -{0x1.410001532aff4p+0, 0x1.7f8375f198524p-57}, -{0x1.4300017478b29p+0, 0x1.301e672dc5143p-55}, -{0x1.44fffe795b463p+0, 0x1.9ff69b8b2895ap-55}, -{0x1.46fffe80475ep+0, -0x1.5c0b19bc2f254p-54}, -{0x1.48fffef6fc1e7p+0, 0x1.b4009f23a2a72p-54}, -{0x1.4afffe5bea704p+0, -0x1.4ffb7bf0d7d45p-54}, -{0x1.4d000171027dep+0, -0x1.9c06471dc6a3dp-54}, -{0x1.4f0000ff03ee2p+0, 0x1.77f890b85531cp-54}, -{0x1.5100012dc4bd1p+0, 0x1.004657166a436p-57}, -{0x1.530001605277ap+0, -0x1.6bfcece233209p-54}, -{0x1.54fffecdb704cp+0, -0x1.902720505a1d7p-55}, -{0x1.56fffef5f54a9p+0, 0x1.bbfe60ec96412p-54}, -{0x1.5900017e61012p+0, 0x1.87ec581afef9p-55}, -{0x1.5b00003c93e92p+0, -0x1.f41080abf0ccp-54}, -{0x1.5d0001d4919bcp+0, -0x1.8812afb254729p-54}, -{0x1.5efffe7b87a89p+0, -0x1.47eb780ed6904p-54}, -}, -#endif -}; diff --git a/lib/libc/musl/src/math/log_data.h b/lib/libc/musl/src/math/log_data.h @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ -#ifndef _LOG_DATA_H -#define _LOG_DATA_H - -#include <features.h> - -#define LOG_TABLE_BITS 7 -#define LOG_POLY_ORDER 6 -#define LOG_POLY1_ORDER 12 -extern hidden const struct log_data { - double ln2hi; - double ln2lo; - double poly[LOG_POLY_ORDER - 1]; /* First coefficient is 1. */ - double poly1[LOG_POLY1_ORDER - 1]; - struct { - double invc, logc; - } tab[1 << LOG_TABLE_BITS]; -#if !__FP_FAST_FMA - struct { - double chi, clo; - } tab2[1 << LOG_TABLE_BITS]; -#endif -} __log_data; - -#endif diff --git a/lib/libc/musl/src/math/logf_data.c b/lib/libc/musl/src/math/logf_data.c @@ -1,33 +0,0 @@ -/* - * Data definition for logf. - * - * Copyright (c) 2017-2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ - -#include "logf_data.h" - -const struct logf_data __logf_data = { - .tab = { - { 0x1.661ec79f8f3bep+0, -0x1.57bf7808caadep-2 }, - { 0x1.571ed4aaf883dp+0, -0x1.2bef0a7c06ddbp-2 }, - { 0x1.49539f0f010bp+0, -0x1.01eae7f513a67p-2 }, - { 0x1.3c995b0b80385p+0, -0x1.b31d8a68224e9p-3 }, - { 0x1.30d190c8864a5p+0, -0x1.6574f0ac07758p-3 }, - { 0x1.25e227b0b8eap+0, -0x1.1aa2bc79c81p-3 }, - { 0x1.1bb4a4a1a343fp+0, -0x1.a4e76ce8c0e5ep-4 }, - { 0x1.12358f08ae5bap+0, -0x1.1973c5a611cccp-4 }, - { 0x1.0953f419900a7p+0, -0x1.252f438e10c1ep-5 }, - { 0x1p+0, 0x0p+0 }, - { 0x1.e608cfd9a47acp-1, 0x1.aa5aa5df25984p-5 }, - { 0x1.ca4b31f026aap-1, 0x1.c5e53aa362eb4p-4 }, - { 0x1.b2036576afce6p-1, 0x1.526e57720db08p-3 }, - { 0x1.9c2d163a1aa2dp-1, 0x1.bc2860d22477p-3 }, - { 0x1.886e6037841edp-1, 0x1.1058bc8a07ee1p-2 }, - { 0x1.767dcf5534862p-1, 0x1.4043057b6ee09p-2 }, - }, - .ln2 = 0x1.62e42fefa39efp-1, - .poly = { - -0x1.00ea348b88334p-2, 0x1.5575b0be00b6ap-2, -0x1.ffffef20a4123p-2, - } -}; diff --git a/lib/libc/musl/src/math/logf_data.h b/lib/libc/musl/src/math/logf_data.h @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2017-2018, Arm Limited. - * SPDX-License-Identifier: MIT - */ -#ifndef _LOGF_DATA_H -#define _LOGF_DATA_H - -#include <features.h> - -#define LOGF_TABLE_BITS 4 -#define LOGF_POLY_ORDER 4 -extern hidden const struct logf_data { - struct { - double invc, logc; - } tab[1 << LOGF_TABLE_BITS]; - double ln2; - double poly[LOGF_POLY_ORDER - 1]; /* First order coefficient is 1. */ -} __logf_data; - -#endif diff --git a/lib/libc/musl/src/math/m68k/sqrtl.c b/lib/libc/musl/src/math/m68k/sqrtl.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __HAVE_68881__ - -long double sqrtl(long double x) -{ - __asm__ ("fsqrt.x %1,%0" : "=f"(x) : "fm"(x)); - return x; -} - -#else - -#include "../sqrtl.c" - -#endif diff --git a/lib/libc/musl/src/math/mips/sqrt.c b/lib/libc/musl/src/math/mips/sqrt.c @@ -1,16 +0,0 @@ -#if !defined(__mips_soft_float) && __mips >= 3 - -#include <math.h> - -double sqrt(double x) -{ - double r; - __asm__("sqrt.d %0,%1" : "=f"(r) : "f"(x)); - return r; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/mips/sqrtf.c b/lib/libc/musl/src/math/mips/sqrtf.c @@ -1,16 +0,0 @@ -#if !defined(__mips_soft_float) && __mips >= 2 - -#include <math.h> - -float sqrtf(float x) -{ - float r; - __asm__("sqrt.s %0,%1" : "=f"(r) : "f"(x)); - return r; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc/sqrt.c b/lib/libc/musl/src/math/powerpc/sqrt.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ - -double sqrt(double x) -{ - __asm__ ("fsqrt %0, %1\n" : "=d" (x) : "d" (x)); - return x; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc/sqrtf.c b/lib/libc/musl/src/math/powerpc/sqrtf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ - -float sqrtf(float x) -{ - __asm__ ("fsqrts %0, %1\n" : "=f" (x) : "f" (x)); - return x; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc64/fmax.c b/lib/libc/musl/src/math/powerpc64/fmax.c @@ -1,15 +0,0 @@ -#include <math.h> - -#ifdef __VSX__ - -double fmax(double x, double y) -{ - __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y)); - return x; -} - -#else - -#include "../fmax.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc64/fmaxf.c b/lib/libc/musl/src/math/powerpc64/fmaxf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#ifdef __VSX__ - -float fmaxf(float x, float y) -{ - __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y)); - return x; -} - -#else - -#include "../fmaxf.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc64/fmin.c b/lib/libc/musl/src/math/powerpc64/fmin.c @@ -1,15 +0,0 @@ -#include <math.h> - -#ifdef __VSX__ - -double fmin(double x, double y) -{ - __asm__ ("xsmindp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y)); - return x; -} - -#else - -#include "../fmin.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc64/fminf.c b/lib/libc/musl/src/math/powerpc64/fminf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#ifdef __VSX__ - -float fminf(float x, float y) -{ - __asm__ ("xsmindp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y)); - return x; -} - -#else - -#include "../fminf.c" - -#endif diff --git a/lib/libc/musl/src/math/powerpc64/sqrt.c b/lib/libc/musl/src/math/powerpc64/sqrt.c @@ -1,7 +0,0 @@ -#include <math.h> - -double sqrt(double x) -{ - __asm__ ("fsqrt %0, %1" : "=d"(x) : "d"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/powerpc64/sqrtf.c b/lib/libc/musl/src/math/powerpc64/sqrtf.c @@ -1,7 +0,0 @@ -#include <math.h> - -float sqrtf(float x) -{ - __asm__ ("fsqrts %0, %1" : "=f"(x) : "f"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/riscv32/copysign.c b/lib/libc/musl/src/math/riscv32/copysign.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double copysign(double x, double y) -{ - __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../copysign.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/copysignf.c b/lib/libc/musl/src/math/riscv32/copysignf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float copysignf(float x, float y) -{ - __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../copysignf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/fmax.c b/lib/libc/musl/src/math/riscv32/fmax.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double fmax(double x, double y) -{ - __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmax.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/fmaxf.c b/lib/libc/musl/src/math/riscv32/fmaxf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float fmaxf(float x, float y) -{ - __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmaxf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/fmin.c b/lib/libc/musl/src/math/riscv32/fmin.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double fmin(double x, double y) -{ - __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmin.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/fminf.c b/lib/libc/musl/src/math/riscv32/fminf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float fminf(float x, float y) -{ - __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fminf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/sqrt.c b/lib/libc/musl/src/math/riscv32/sqrt.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double sqrt(double x) -{ - __asm__ ("fsqrt.d %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv32/sqrtf.c b/lib/libc/musl/src/math/riscv32/sqrtf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float sqrtf(float x) -{ - __asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/copysign.c b/lib/libc/musl/src/math/riscv64/copysign.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double copysign(double x, double y) -{ - __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../copysign.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/copysignf.c b/lib/libc/musl/src/math/riscv64/copysignf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float copysignf(float x, float y) -{ - __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../copysignf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/fmax.c b/lib/libc/musl/src/math/riscv64/fmax.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double fmax(double x, double y) -{ - __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmax.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/fmaxf.c b/lib/libc/musl/src/math/riscv64/fmaxf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float fmaxf(float x, float y) -{ - __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmaxf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/fmin.c b/lib/libc/musl/src/math/riscv64/fmin.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double fmin(double x, double y) -{ - __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fmin.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/fminf.c b/lib/libc/musl/src/math/riscv64/fminf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float fminf(float x, float y) -{ - __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y)); - return x; -} - -#else - -#include "../fminf.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/sqrt.c b/lib/libc/musl/src/math/riscv64/sqrt.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 64 - -double sqrt(double x) -{ - __asm__ ("fsqrt.d %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/riscv64/sqrtf.c b/lib/libc/musl/src/math/riscv64/sqrtf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if __riscv_flen >= 32 - -float sqrtf(float x) -{ - __asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/s390x/sqrt.c b/lib/libc/musl/src/math/s390x/sqrt.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if defined(__HTM__) || __ARCH__ >= 9 - -double sqrt(double x) -{ - __asm__ ("sqdbr %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrt.c" - -#endif diff --git a/lib/libc/musl/src/math/s390x/sqrtf.c b/lib/libc/musl/src/math/s390x/sqrtf.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if defined(__HTM__) || __ARCH__ >= 9 - -float sqrtf(float x) -{ - __asm__ ("sqebr %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrtf.c" - -#endif diff --git a/lib/libc/musl/src/math/s390x/sqrtl.c b/lib/libc/musl/src/math/s390x/sqrtl.c @@ -1,15 +0,0 @@ -#include <math.h> - -#if defined(__HTM__) || __ARCH__ >= 9 - -long double sqrtl(long double x) -{ - __asm__ ("sqxbr %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../sqrtl.c" - -#endif diff --git a/lib/libc/musl/src/math/sqrt.c b/lib/libc/musl/src/math/sqrt.c @@ -1,158 +0,0 @@ -#include <stdint.h> -#include <math.h> -#include "libm.h" -#include "sqrt_data.h" - -#define FENV_SUPPORT 1 - -/* returns a*b*2^-32 - e, with error 0 <= e < 1. */ -static inline uint32_t mul32(uint32_t a, uint32_t b) -{ - return (uint64_t)a*b >> 32; -} - -/* returns a*b*2^-64 - e, with error 0 <= e < 3. */ -static inline uint64_t mul64(uint64_t a, uint64_t b) -{ - uint64_t ahi = a>>32; - uint64_t alo = a&0xffffffff; - uint64_t bhi = b>>32; - uint64_t blo = b&0xffffffff; - return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); -} - -double sqrt(double x) -{ - uint64_t ix, top, m; - - /* special case handling. */ - ix = asuint64(x); - top = ix >> 52; - if (predict_false(top - 0x001 >= 0x7ff - 0x001)) { - /* x < 0x1p-1022 or inf or nan. */ - if (ix * 2 == 0) - return x; - if (ix == 0x7ff0000000000000) - return x; - if (ix > 0x7ff0000000000000) - return __math_invalid(x); - /* x is subnormal, normalize it. */ - ix = asuint64(x * 0x1p52); - top = ix >> 52; - top -= 52; - } - - /* argument reduction: - x = 4^e m; with integer e, and m in [1, 4) - m: fixed point representation [2.62] - 2^e is the exponent part of the result. */ - int even = top & 1; - m = (ix << 11) | 0x8000000000000000; - if (even) m >>= 1; - top = (top + 0x3ff) >> 1; - - /* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4) - - initial estimate: - 7bit table lookup (1bit exponent and 6bit significand). - - iterative approximation: - using 2 goldschmidt iterations with 32bit int arithmetics - and a final iteration with 64bit int arithmetics. - - details: - - the relative error (e = r0 sqrt(m)-1) of a linear estimate - (r0 = a m + b) is |e| < 0.085955 ~ 0x1.6p-4 at best, - a table lookup is faster and needs one less iteration - 6 bit lookup table (128b) gives |e| < 0x1.f9p-8 - 7 bit lookup table (256b) gives |e| < 0x1.fdp-9 - for single and double prec 6bit is enough but for quad - prec 7bit is needed (or modified iterations). to avoid - one more iteration >=13bit table would be needed (16k). - - a newton-raphson iteration for r is - w = r*r - u = 3 - m*w - r = r*u/2 - can use a goldschmidt iteration for s at the end or - s = m*r - - first goldschmidt iteration is - s = m*r - u = 3 - s*r - r = r*u/2 - s = s*u/2 - next goldschmidt iteration is - u = 3 - s*r - r = r*u/2 - s = s*u/2 - and at the end r is not computed only s. - - they use the same amount of operations and converge at the - same quadratic rate, i.e. if - r1 sqrt(m) - 1 = e, then - r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3 - the advantage of goldschmidt is that the mul for s and r - are independent (computed in parallel), however it is not - "self synchronizing": it only uses the input m in the - first iteration so rounding errors accumulate. at the end - or when switching to larger precision arithmetics rounding - errors dominate so the first iteration should be used. - - the fixed point representations are - m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 - and after switching to 64 bit - m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */ - - static const uint64_t three = 0xc0000000; - uint64_t r, s, d, u, i; - - i = (ix >> 46) % 128; - r = (uint32_t)__rsqrt_tab[i] << 16; - /* |r sqrt(m) - 1| < 0x1.fdp-9 */ - s = mul32(m>>32, r); - /* |s/sqrt(m) - 1| < 0x1.fdp-9 */ - d = mul32(s, r); - u = three - d; - r = mul32(r, u) << 1; - /* |r sqrt(m) - 1| < 0x1.7bp-16 */ - s = mul32(s, u) << 1; - /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ - d = mul32(s, r); - u = three - d; - r = mul32(r, u) << 1; - /* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */ - r = r << 32; - s = mul64(m, r); - d = mul64(s, r); - u = (three<<32) - d; - s = mul64(s, u); /* repr: 3.61 */ - /* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */ - s = (s - 2) >> 9; /* repr: 12.52 */ - /* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */ - - /* s < sqrt(m) < s + 0x1.09p-52, - compute nearest rounded result: - the nearest result to 52 bits is either s or s+0x1p-52, - we can decide by comparing (2^52 s + 0.5)^2 to 2^104 m. */ - uint64_t d0, d1, d2; - double y, t; - d0 = (m << 42) - s*s; - d1 = s - d0; - d2 = d1 + s + 1; - s += d1 >> 63; - s &= 0x000fffffffffffff; - s |= top << 52; - y = asdouble(s); - if (FENV_SUPPORT) { - /* handle rounding modes and inexact exception: - only (s+1)^2 == 2^42 m case is exact otherwise - add a tiny value to cause the fenv effects. */ - uint64_t tiny = predict_false(d2==0) ? 0 : 0x0010000000000000; - tiny |= (d1^d2) & 0x8000000000000000; - t = asdouble(tiny); - y = eval_as_double(y + t); - } - return y; -} diff --git a/lib/libc/musl/src/math/sqrt_data.c b/lib/libc/musl/src/math/sqrt_data.c @@ -1,19 +0,0 @@ -#include "sqrt_data.h" -const uint16_t __rsqrt_tab[128] = { -0xb451,0xb2f0,0xb196,0xb044,0xaef9,0xadb6,0xac79,0xab43, -0xaa14,0xa8eb,0xa7c8,0xa6aa,0xa592,0xa480,0xa373,0xa26b, -0xa168,0xa06a,0x9f70,0x9e7b,0x9d8a,0x9c9d,0x9bb5,0x9ad1, -0x99f0,0x9913,0x983a,0x9765,0x9693,0x95c4,0x94f8,0x9430, -0x936b,0x92a9,0x91ea,0x912e,0x9075,0x8fbe,0x8f0a,0x8e59, -0x8daa,0x8cfe,0x8c54,0x8bac,0x8b07,0x8a64,0x89c4,0x8925, -0x8889,0x87ee,0x8756,0x86c0,0x862b,0x8599,0x8508,0x8479, -0x83ec,0x8361,0x82d8,0x8250,0x81c9,0x8145,0x80c2,0x8040, -0xff02,0xfd0e,0xfb25,0xf947,0xf773,0xf5aa,0xf3ea,0xf234, -0xf087,0xeee3,0xed47,0xebb3,0xea27,0xe8a3,0xe727,0xe5b2, -0xe443,0xe2dc,0xe17a,0xe020,0xdecb,0xdd7d,0xdc34,0xdaf1, -0xd9b3,0xd87b,0xd748,0xd61a,0xd4f1,0xd3cd,0xd2ad,0xd192, -0xd07b,0xcf69,0xce5b,0xcd51,0xcc4a,0xcb48,0xca4a,0xc94f, -0xc858,0xc764,0xc674,0xc587,0xc49d,0xc3b7,0xc2d4,0xc1f4, -0xc116,0xc03c,0xbf65,0xbe90,0xbdbe,0xbcef,0xbc23,0xbb59, -0xba91,0xb9cc,0xb90a,0xb84a,0xb78c,0xb6d0,0xb617,0xb560, -}; diff --git a/lib/libc/musl/src/math/sqrt_data.h b/lib/libc/musl/src/math/sqrt_data.h @@ -1,13 +0,0 @@ -#ifndef _SQRT_DATA_H -#define _SQRT_DATA_H - -#include <features.h> -#include <stdint.h> - -/* if x in [1,2): i = (int)(64*x); - if x in [2,4): i = (int)(32*x-64); - __rsqrt_tab[i]*2^-16 is estimating 1/sqrt(x) with small relative error: - |__rsqrt_tab[i]*0x1p-16*sqrt(x) - 1| < -0x1.fdp-9 < 2^-8 */ -extern hidden const uint16_t __rsqrt_tab[128]; - -#endif diff --git a/lib/libc/musl/src/math/sqrtf.c b/lib/libc/musl/src/math/sqrtf.c @@ -1,83 +0,0 @@ -#include <stdint.h> -#include <math.h> -#include "libm.h" -#include "sqrt_data.h" - -#define FENV_SUPPORT 1 - -static inline uint32_t mul32(uint32_t a, uint32_t b) -{ - return (uint64_t)a*b >> 32; -} - -/* see sqrt.c for more detailed comments. */ - -float sqrtf(float x) -{ - uint32_t ix, m, m1, m0, even, ey; - - ix = asuint(x); - if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) { - /* x < 0x1p-126 or inf or nan. */ - if (ix * 2 == 0) - return x; - if (ix == 0x7f800000) - return x; - if (ix > 0x7f800000) - return __math_invalidf(x); - /* x is subnormal, normalize it. */ - ix = asuint(x * 0x1p23f); - ix -= 23 << 23; - } - - /* x = 4^e m; with int e and m in [1, 4). */ - even = ix & 0x00800000; - m1 = (ix << 8) | 0x80000000; - m0 = (ix << 7) & 0x7fffffff; - m = even ? m0 : m1; - - /* 2^e is the exponent part of the return value. */ - ey = ix >> 1; - ey += 0x3f800000 >> 1; - ey &= 0x7f800000; - - /* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */ - static const uint32_t three = 0xc0000000; - uint32_t r, s, d, u, i; - i = (ix >> 17) % 128; - r = (uint32_t)__rsqrt_tab[i] << 16; - /* |r*sqrt(m) - 1| < 0x1p-8 */ - s = mul32(m, r); - /* |s/sqrt(m) - 1| < 0x1p-8 */ - d = mul32(s, r); - u = three - d; - r = mul32(r, u) << 1; - /* |r*sqrt(m) - 1| < 0x1.7bp-16 */ - s = mul32(s, u) << 1; - /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ - d = mul32(s, r); - u = three - d; - s = mul32(s, u); - /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */ - s = (s - 1)>>6; - /* s < sqrt(m) < s + 0x1.08p-23 */ - - /* compute nearest rounded result. */ - uint32_t d0, d1, d2; - float y, t; - d0 = (m << 16) - s*s; - d1 = s - d0; - d2 = d1 + s + 1; - s += d1 >> 31; - s &= 0x007fffff; - s |= ey; - y = asfloat(s); - if (FENV_SUPPORT) { - /* handle rounding and inexact exception. */ - uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000; - tiny |= (d1^d2) & 0x80000000; - t = asfloat(tiny); - y = eval_as_float(y + t); - } - return y; -} diff --git a/lib/libc/musl/src/math/sqrtl.c b/lib/libc/musl/src/math/sqrtl.c @@ -1,259 +0,0 @@ -#include <stdint.h> -#include <math.h> -#include <float.h> -#include "libm.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double sqrtl(long double x) -{ - return sqrt(x); -} -#elif (LDBL_MANT_DIG == 113 || LDBL_MANT_DIG == 64) && LDBL_MAX_EXP == 16384 -#include "sqrt_data.h" - -#define FENV_SUPPORT 1 - -typedef struct { - uint64_t hi; - uint64_t lo; -} u128; - -/* top: 16 bit sign+exponent, x: significand. */ -static inline long double mkldbl(uint64_t top, u128 x) -{ - union ldshape u; -#if LDBL_MANT_DIG == 113 - u.i2.hi = x.hi; - u.i2.lo = x.lo; - u.i2.hi &= 0x0000ffffffffffff; - u.i2.hi |= top << 48; -#elif LDBL_MANT_DIG == 64 - u.i.se = top; - u.i.m = x.lo; - /* force the top bit on non-zero (and non-subnormal) results. */ - if (top & 0x7fff) - u.i.m |= 0x8000000000000000; -#endif - return u.f; -} - -/* return: top 16 bit is sign+exp and following bits are the significand. */ -static inline u128 asu128(long double x) -{ - union ldshape u = {.f=x}; - u128 r; -#if LDBL_MANT_DIG == 113 - r.hi = u.i2.hi; - r.lo = u.i2.lo; -#elif LDBL_MANT_DIG == 64 - r.lo = u.i.m<<49; - /* ignore the top bit: pseudo numbers are not handled. */ - r.hi = u.i.m>>15; - r.hi &= 0x0000ffffffffffff; - r.hi |= (uint64_t)u.i.se << 48; -#endif - return r; -} - -/* returns a*b*2^-32 - e, with error 0 <= e < 1. */ -static inline uint32_t mul32(uint32_t a, uint32_t b) -{ - return (uint64_t)a*b >> 32; -} - -/* returns a*b*2^-64 - e, with error 0 <= e < 3. */ -static inline uint64_t mul64(uint64_t a, uint64_t b) -{ - uint64_t ahi = a>>32; - uint64_t alo = a&0xffffffff; - uint64_t bhi = b>>32; - uint64_t blo = b&0xffffffff; - return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); -} - -static inline u128 add64(u128 a, uint64_t b) -{ - u128 r; - r.lo = a.lo + b; - r.hi = a.hi; - if (r.lo < a.lo) - r.hi++; - return r; -} - -static inline u128 add128(u128 a, u128 b) -{ - u128 r; - r.lo = a.lo + b.lo; - r.hi = a.hi + b.hi; - if (r.lo < a.lo) - r.hi++; - return r; -} - -static inline u128 sub64(u128 a, uint64_t b) -{ - u128 r; - r.lo = a.lo - b; - r.hi = a.hi; - if (a.lo < b) - r.hi--; - return r; -} - -static inline u128 sub128(u128 a, u128 b) -{ - u128 r; - r.lo = a.lo - b.lo; - r.hi = a.hi - b.hi; - if (a.lo < b.lo) - r.hi--; - return r; -} - -/* a<<n, 0 <= n <= 127 */ -static inline u128 lsh(u128 a, int n) -{ - if (n == 0) - return a; - if (n >= 64) { - a.hi = a.lo<<(n-64); - a.lo = 0; - } else { - a.hi = (a.hi<<n) | (a.lo>>(64-n)); - a.lo = a.lo<<n; - } - return a; -} - -/* a>>n, 0 <= n <= 127 */ -static inline u128 rsh(u128 a, int n) -{ - if (n == 0) - return a; - if (n >= 64) { - a.lo = a.hi>>(n-64); - a.hi = 0; - } else { - a.lo = (a.lo>>n) | (a.hi<<(64-n)); - a.hi = a.hi>>n; - } - return a; -} - -/* returns a*b exactly. */ -static inline u128 mul64_128(uint64_t a, uint64_t b) -{ - u128 r; - uint64_t ahi = a>>32; - uint64_t alo = a&0xffffffff; - uint64_t bhi = b>>32; - uint64_t blo = b&0xffffffff; - uint64_t lo1 = ((ahi*blo)&0xffffffff) + ((alo*bhi)&0xffffffff) + (alo*blo>>32); - uint64_t lo2 = (alo*blo)&0xffffffff; - r.hi = ahi*bhi + (ahi*blo>>32) + (alo*bhi>>32) + (lo1>>32); - r.lo = (lo1<<32) + lo2; - return r; -} - -/* returns a*b*2^-128 - e, with error 0 <= e < 7. */ -static inline u128 mul128(u128 a, u128 b) -{ - u128 hi = mul64_128(a.hi, b.hi); - uint64_t m1 = mul64(a.hi, b.lo); - uint64_t m2 = mul64(a.lo, b.hi); - return add64(add64(hi, m1), m2); -} - -/* returns a*b % 2^128. */ -static inline u128 mul128_tail(u128 a, u128 b) -{ - u128 lo = mul64_128(a.lo, b.lo); - lo.hi += a.hi*b.lo + a.lo*b.hi; - return lo; -} - - -/* see sqrt.c for detailed comments. */ - -long double sqrtl(long double x) -{ - u128 ix, ml; - uint64_t top; - - ix = asu128(x); - top = ix.hi >> 48; - if (predict_false(top - 0x0001 >= 0x7fff - 0x0001)) { - /* x < 0x1p-16382 or inf or nan. */ - if (2*ix.hi == 0 && ix.lo == 0) - return x; - if (ix.hi == 0x7fff000000000000 && ix.lo == 0) - return x; - if (top >= 0x7fff) - return __math_invalidl(x); - /* x is subnormal, normalize it. */ - ix = asu128(x * 0x1p112); - top = ix.hi >> 48; - top -= 112; - } - - /* x = 4^e m; with int e and m in [1, 4) */ - int even = top & 1; - ml = lsh(ix, 15); - ml.hi |= 0x8000000000000000; - if (even) ml = rsh(ml, 1); - top = (top + 0x3fff) >> 1; - - /* r ~ 1/sqrt(m) */ - const uint64_t three = 0xc0000000; - uint64_t r, s, d, u, i; - i = (ix.hi >> 42) % 128; - r = (uint32_t)__rsqrt_tab[i] << 16; - /* |r sqrt(m) - 1| < 0x1p-8 */ - s = mul32(ml.hi>>32, r); - d = mul32(s, r); - u = three - d; - r = mul32(u, r) << 1; - /* |r sqrt(m) - 1| < 0x1.7bp-16, switch to 64bit */ - r = r<<32; - s = mul64(ml.hi, r); - d = mul64(s, r); - u = (three<<32) - d; - r = mul64(u, r) << 1; - /* |r sqrt(m) - 1| < 0x1.a5p-31 */ - s = mul64(u, s) << 1; - d = mul64(s, r); - u = (three<<32) - d; - r = mul64(u, r) << 1; - /* |r sqrt(m) - 1| < 0x1.c001p-59, switch to 128bit */ - - const u128 threel = {.hi=three<<32, .lo=0}; - u128 rl, sl, dl, ul; - rl.hi = r; - rl.lo = 0; - sl = mul128(ml, rl); - dl = mul128(sl, rl); - ul = sub128(threel, dl); - sl = mul128(ul, sl); /* repr: 3.125 */ - /* -0x1p-116 < s - sqrt(m) < 0x3.8001p-125 */ - sl = rsh(sub64(sl, 4), 125-(LDBL_MANT_DIG-1)); - /* s < sqrt(m) < s + 1 ULP + tiny */ - - long double y; - u128 d2, d1, d0; - d0 = sub128(lsh(ml, 2*(LDBL_MANT_DIG-1)-126), mul128_tail(sl,sl)); - d1 = sub128(sl, d0); - d2 = add128(add64(sl, 1), d1); - sl = add64(sl, d1.hi >> 63); - y = mkldbl(top, sl); - if (FENV_SUPPORT) { - /* handle rounding modes and inexact exception. */ - top = predict_false((d2.hi|d2.lo)==0) ? 0 : 1; - top |= ((d1.hi^d2.hi)&0x8000000000000000) >> 48; - y += mkldbl(top, (u128){0}); - } - return y; -} -#else -#error unsupported long double format -#endif diff --git a/lib/libc/musl/src/math/x32/fmodl.s b/lib/libc/musl/src/math/x32/fmodl.s @@ -1,11 +0,0 @@ -.global fmodl -.type fmodl,@function -fmodl: - fldt 24(%esp) - fldt 8(%esp) -1: fprem - fnstsw %ax - testb $4,%ah - jnz 1b - fstp %st(1) - ret diff --git a/lib/libc/musl/src/math/x32/sqrt.s b/lib/libc/musl/src/math/x32/sqrt.s @@ -1,4 +0,0 @@ -.global sqrt -.type sqrt,@function -sqrt: sqrtsd %xmm0, %xmm0 - ret diff --git a/lib/libc/musl/src/math/x32/sqrtf.s b/lib/libc/musl/src/math/x32/sqrtf.s @@ -1,4 +0,0 @@ -.global sqrtf -.type sqrtf,@function -sqrtf: sqrtss %xmm0, %xmm0 - ret diff --git a/lib/libc/musl/src/math/x32/sqrtl.s b/lib/libc/musl/src/math/x32/sqrtl.s @@ -1,5 +0,0 @@ -.global sqrtl -.type sqrtl,@function -sqrtl: fldt 8(%esp) - fsqrt - ret diff --git a/lib/libc/musl/src/math/x86_64/fmodl.c b/lib/libc/musl/src/math/x86_64/fmodl.c @@ -1,9 +0,0 @@ -#include <math.h> - -long double fmodl(long double x, long double y) -{ - unsigned short fpsr; - do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); - while (fpsr & 0x400); - return x; -} diff --git a/lib/libc/musl/src/math/x86_64/sqrt.c b/lib/libc/musl/src/math/x86_64/sqrt.c @@ -1,7 +0,0 @@ -#include <math.h> - -double sqrt(double x) -{ - __asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/x86_64/sqrtf.c b/lib/libc/musl/src/math/x86_64/sqrtf.c @@ -1,7 +0,0 @@ -#include <math.h> - -float sqrtf(float x) -{ - __asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/x86_64/sqrtl.c b/lib/libc/musl/src/math/x86_64/sqrtl.c @@ -1,7 +0,0 @@ -#include <math.h> - -long double sqrtl(long double x) -{ - __asm__ ("fsqrt" : "+t"(x)); - return x; -} diff --git a/lib/libc/wasi/libc-bottom-half/sources/math/fmin-fmax.c b/lib/libc/wasi/libc-bottom-half/sources/math/fmin-fmax.c @@ -1,34 +0,0 @@ -// Wasm's `min` and `max` operators implement the IEEE 754-2019 -// `minimum` and `maximum` operations, meaning that given a choice -// between NaN and a number, they return NaN. This differs from -// the C standard library's `fmin` and `fmax` functions, which -// return the number. However, we can still use wasm's builtins -// by handling the NaN cases explicitly, and it still turns out -// to be faster than doing the whole operation in -// target-independent C. And, it's smaller. - -#include <math.h> - -float fminf(float x, float y) { - if (isnan(x)) return y; - if (isnan(y)) return x; - return __builtin_wasm_min_f32(x, y); -} - -float fmaxf(float x, float y) { - if (isnan(x)) return y; - if (isnan(y)) return x; - return __builtin_wasm_max_f32(x, y); -} - -double fmin(double x, double y) { - if (isnan(x)) return y; - if (isnan(y)) return x; - return __builtin_wasm_min_f64(x, y); -} - -double fmax(double x, double y) { - if (isnan(x)) return y; - if (isnan(y)) return x; - return __builtin_wasm_max_f64(x, y); -} diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig @@ -630,7 +630,6 @@ const mingw32_generic_src = [_][]const u8{ "math" ++ path.sep_str ++ "signbitl.c", "math" ++ path.sep_str ++ "signgam.c", "math" ++ path.sep_str ++ "sinhl.c", - "math" ++ path.sep_str ++ "sqrtl.c", "math" ++ path.sep_str ++ "tanhl.c", "misc" ++ path.sep_str ++ "alarm.c", "misc" ++ path.sep_str ++ "btowc.c", @@ -942,8 +941,6 @@ const mingw32_x86_src = [_][]const u8{ "math" ++ path.sep_str ++ "erfl.c", "math" ++ path.sep_str ++ "fdiml.c", "math" ++ path.sep_str ++ "fmal.c", - "math" ++ path.sep_str ++ "fmaxl.c", - "math" ++ path.sep_str ++ "fminl.c", "math" ++ path.sep_str ++ "llrintl.c", "math" ++ path.sep_str ++ "llroundl.c", "math" ++ path.sep_str ++ "lrintl.c", @@ -959,14 +956,12 @@ const mingw32_x86_src = [_][]const u8{ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c", - "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expm1l.c", - "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fucom.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ilogbl.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "internal_logl.S", @@ -999,13 +994,11 @@ const mingw32_x86_32_src = [_][]const u8{ "math" ++ path.sep_str ++ "modff.c", "math" ++ path.sep_str ++ "powf.c", "math" ++ path.sep_str ++ "sinhf.c", - "math" ++ path.sep_str ++ "sqrtf.c", "math" ++ path.sep_str ++ "tanhf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c", - "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c", }; const mingw32_arm_src = [_][]const u8{ diff --git a/src/libs/musl.zig b/src/libs/musl.zig @@ -812,10 +812,6 @@ const src_files = [_][]const u8{ "musl/src/malloc/replaced.c", "musl/src/math/aarch64/fma.c", "musl/src/math/aarch64/fmaf.c", - "musl/src/math/aarch64/fmax.c", - "musl/src/math/aarch64/fmaxf.c", - "musl/src/math/aarch64/fmin.c", - "musl/src/math/aarch64/fminf.c", "musl/src/math/aarch64/llrint.c", "musl/src/math/aarch64/llrintf.c", "musl/src/math/aarch64/llround.c", @@ -830,8 +826,6 @@ const src_files = [_][]const u8{ "musl/src/math/aarch64/rintf.c", "musl/src/math/aarch64/round.c", "musl/src/math/aarch64/roundf.c", - "musl/src/math/aarch64/sqrt.c", - "musl/src/math/aarch64/sqrtf.c", "musl/src/math/acos.c", "musl/src/math/acosf.c", "musl/src/math/acosh.c", @@ -840,8 +834,6 @@ const src_files = [_][]const u8{ "musl/src/math/acosl.c", "musl/src/math/arm/fma.c", "musl/src/math/arm/fmaf.c", - "musl/src/math/arm/sqrt.c", - "musl/src/math/arm/sqrtf.c", "musl/src/math/asin.c", "musl/src/math/asinf.c", "musl/src/math/asinh.c", @@ -860,9 +852,6 @@ const src_files = [_][]const u8{ "musl/src/math/cbrt.c", "musl/src/math/cbrtf.c", "musl/src/math/cbrtl.c", - "musl/src/math/copysign.c", - "musl/src/math/copysignf.c", - "musl/src/math/copysignl.c", "musl/src/math/__cos.c", "musl/src/math/__cosdf.c", "musl/src/math/cosh.c", @@ -893,12 +882,6 @@ const src_files = [_][]const u8{ "musl/src/math/fma.c", "musl/src/math/fmaf.c", "musl/src/math/fmal.c", - "musl/src/math/fmax.c", - "musl/src/math/fmaxf.c", - "musl/src/math/fmaxl.c", - "musl/src/math/fmin.c", - "musl/src/math/fminf.c", - "musl/src/math/fminl.c", "musl/src/math/__fpclassify.c", "musl/src/math/__fpclassifyf.c", "musl/src/math/__fpclassifyl.c", @@ -924,9 +907,6 @@ const src_files = [_][]const u8{ "musl/src/math/i386/exp_ld.s", "musl/src/math/i386/expl.s", "musl/src/math/i386/expm1l.s", - "musl/src/math/i386/fmod.c", - "musl/src/math/i386/fmodf.c", - "musl/src/math/i386/fmodl.c", "musl/src/math/i386/hypotf.s", "musl/src/math/i386/hypot.s", "musl/src/math/i386/__invtrigl.s", @@ -936,18 +916,12 @@ const src_files = [_][]const u8{ "musl/src/math/i386/llrint.c", "musl/src/math/i386/llrintf.c", "musl/src/math/i386/llrintl.c", - "musl/src/math/i386/log10f.s", "musl/src/math/i386/log10l.s", - "musl/src/math/i386/log10.s", "musl/src/math/i386/log1pf.s", "musl/src/math/i386/log1pl.s", "musl/src/math/i386/log1p.s", - "musl/src/math/i386/log2f.s", "musl/src/math/i386/log2l.s", - "musl/src/math/i386/log2.s", - "musl/src/math/i386/logf.s", "musl/src/math/i386/logl.s", - "musl/src/math/i386/log.s", "musl/src/math/i386/lrint.c", "musl/src/math/i386/lrintf.c", "musl/src/math/i386/lrintl.c", @@ -966,9 +940,6 @@ const src_files = [_][]const u8{ "musl/src/math/i386/scalbnf.s", "musl/src/math/i386/scalbnl.s", "musl/src/math/i386/scalbn.s", - "musl/src/math/i386/sqrt.c", - "musl/src/math/i386/sqrtf.c", - "musl/src/math/i386/sqrtl.c", "musl/src/math/ilogb.c", "musl/src/math/ilogbf.c", "musl/src/math/ilogbl.c", @@ -997,14 +968,10 @@ const src_files = [_][]const u8{ "musl/src/math/log1p.c", "musl/src/math/log1pf.c", "musl/src/math/log1pl.c", - "musl/src/math/log2_data.c", - "musl/src/math/log2f_data.c", "musl/src/math/log2l.c", "musl/src/math/logb.c", "musl/src/math/logbf.c", "musl/src/math/logbl.c", - "musl/src/math/log_data.c", - "musl/src/math/logf_data.c", "musl/src/math/logl.c", "musl/src/math/lrint.c", "musl/src/math/lrintf.c", @@ -1012,7 +979,6 @@ const src_files = [_][]const u8{ "musl/src/math/lround.c", "musl/src/math/lroundf.c", "musl/src/math/lroundl.c", - "musl/src/math/m68k/sqrtl.c", "musl/src/math/__math_divzero.c", "musl/src/math/__math_divzerof.c", "musl/src/math/__math_invalid.c", @@ -1024,8 +990,6 @@ const src_files = [_][]const u8{ "musl/src/math/__math_uflowf.c", "musl/src/math/__math_xflow.c", "musl/src/math/__math_xflowf.c", - "musl/src/math/mips/sqrt.c", - "musl/src/math/mips/sqrtf.c", "musl/src/math/modf.c", "musl/src/math/modff.c", "musl/src/math/modfl.c", @@ -1043,22 +1007,14 @@ const src_files = [_][]const u8{ "musl/src/math/pow_data.c", "musl/src/math/powerpc64/fma.c", "musl/src/math/powerpc64/fmaf.c", - "musl/src/math/powerpc64/fmax.c", - "musl/src/math/powerpc64/fmaxf.c", - "musl/src/math/powerpc64/fmin.c", - "musl/src/math/powerpc64/fminf.c", "musl/src/math/powerpc64/lrint.c", "musl/src/math/powerpc64/lrintf.c", "musl/src/math/powerpc64/lround.c", "musl/src/math/powerpc64/lroundf.c", "musl/src/math/powerpc64/round.c", "musl/src/math/powerpc64/roundf.c", - "musl/src/math/powerpc64/sqrt.c", - "musl/src/math/powerpc64/sqrtf.c", "musl/src/math/powerpc/fma.c", "musl/src/math/powerpc/fmaf.c", - "musl/src/math/powerpc/sqrt.c", - "musl/src/math/powerpc/sqrtf.c", "musl/src/math/powf.c", "musl/src/math/powf_data.c", "musl/src/math/powl.c", @@ -1075,26 +1031,10 @@ const src_files = [_][]const u8{ "musl/src/math/rint.c", "musl/src/math/rintf.c", "musl/src/math/rintl.c", - "musl/src/math/riscv32/copysign.c", - "musl/src/math/riscv32/copysignf.c", "musl/src/math/riscv32/fma.c", "musl/src/math/riscv32/fmaf.c", - "musl/src/math/riscv32/fmax.c", - "musl/src/math/riscv32/fmaxf.c", - "musl/src/math/riscv32/fmin.c", - "musl/src/math/riscv32/fminf.c", - "musl/src/math/riscv32/sqrt.c", - "musl/src/math/riscv32/sqrtf.c", - "musl/src/math/riscv64/copysign.c", - "musl/src/math/riscv64/copysignf.c", "musl/src/math/riscv64/fma.c", "musl/src/math/riscv64/fmaf.c", - "musl/src/math/riscv64/fmax.c", - "musl/src/math/riscv64/fmaxf.c", - "musl/src/math/riscv64/fmin.c", - "musl/src/math/riscv64/fminf.c", - "musl/src/math/riscv64/sqrt.c", - "musl/src/math/riscv64/sqrtf.c", "musl/src/math/round.c", "musl/src/math/roundf.c", "musl/src/math/roundl.c", @@ -1109,9 +1049,6 @@ const src_files = [_][]const u8{ "musl/src/math/s390x/round.c", "musl/src/math/s390x/roundf.c", "musl/src/math/s390x/roundl.c", - "musl/src/math/s390x/sqrt.c", - "musl/src/math/s390x/sqrtf.c", - "musl/src/math/s390x/sqrtl.c", "musl/src/math/scalb.c", "musl/src/math/scalbf.c", "musl/src/math/scalbln.c", @@ -1134,10 +1071,6 @@ const src_files = [_][]const u8{ "musl/src/math/sinhl.c", "musl/src/math/__sinl.c", "musl/src/math/sinl.c", - "musl/src/math/sqrt.c", - "musl/src/math/sqrt_data.c", - "musl/src/math/sqrtf.c", - "musl/src/math/sqrtl.c", "musl/src/math/__tan.c", "musl/src/math/__tandf.c", "musl/src/math/tanh.c", @@ -1157,7 +1090,6 @@ const src_files = [_][]const u8{ "musl/src/math/x32/expm1l.s", "musl/src/math/x32/fma.c", "musl/src/math/x32/fmaf.c", - "musl/src/math/x32/fmodl.s", "musl/src/math/x32/__invtrigl.s", "musl/src/math/x32/llrintf.s", "musl/src/math/x32/llrintl.s", @@ -1171,9 +1103,6 @@ const src_files = [_][]const u8{ "musl/src/math/x32/lrint.s", "musl/src/math/x32/remainderl.s", "musl/src/math/x32/rintl.s", - "musl/src/math/x32/sqrtf.s", - "musl/src/math/x32/sqrtl.s", - "musl/src/math/x32/sqrt.s", "musl/src/math/x86_64/acosl.s", "musl/src/math/x86_64/asinl.s", "musl/src/math/x86_64/atan2l.s", @@ -1183,7 +1112,6 @@ const src_files = [_][]const u8{ "musl/src/math/x86_64/expm1l.s", "musl/src/math/x86_64/fma.c", "musl/src/math/x86_64/fmaf.c", - "musl/src/math/x86_64/fmodl.c", "musl/src/math/x86_64/__invtrigl.s", "musl/src/math/x86_64/llrint.c", "musl/src/math/x86_64/llrintf.c", @@ -1198,9 +1126,6 @@ const src_files = [_][]const u8{ "musl/src/math/x86_64/remainderl.c", "musl/src/math/x86_64/remquol.c", "musl/src/math/x86_64/rintl.c", - "musl/src/math/x86_64/sqrt.c", - "musl/src/math/x86_64/sqrtf.c", - "musl/src/math/x86_64/sqrtl.c", "musl/src/misc/a64l.c", "musl/src/misc/basename.c", "musl/src/misc/dirname.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig @@ -547,7 +547,6 @@ const libc_bottom_half_src_files = [_][]const u8{ "wasi/libc-bottom-half/sources/getentropy.c", "wasi/libc-bottom-half/sources/isatty.c", "wasi/libc-bottom-half/sources/__main_void.c", - "wasi/libc-bottom-half/sources/math/fmin-fmax.c", "wasi/libc-bottom-half/sources/math/math-builtins.c", "wasi/libc-bottom-half/sources/posix.c", "wasi/libc-bottom-half/sources/preopens.c", @@ -711,7 +710,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/cbrt.c", "musl/src/math/cbrtf.c", "musl/src/math/cbrtl.c", - "musl/src/math/copysignl.c", "musl/src/math/__cos.c", "musl/src/math/__cosdf.c", "musl/src/math/coshl.c", @@ -737,8 +735,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/fmaxl.c", - "musl/src/math/fminl.c", "musl/src/math/frexp.c", "musl/src/math/frexpf.c", "musl/src/math/frexpl.c", @@ -773,14 +769,10 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/log1p.c", "musl/src/math/log1pf.c", "musl/src/math/log1pl.c", - "musl/src/math/log2_data.c", - "musl/src/math/log2f_data.c", "musl/src/math/log2l.c", "musl/src/math/logb.c", "musl/src/math/logbf.c", "musl/src/math/logbl.c", - "musl/src/math/log_data.c", - "musl/src/math/logf_data.c", "musl/src/math/logl.c", "musl/src/math/lrint.c", "musl/src/math/lrintf.c", @@ -842,8 +834,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/sinhl.c", "musl/src/math/__sinl.c", "musl/src/math/sinl.c", - "musl/src/math/sqrt_data.c", - "musl/src/math/sqrtl.c", "musl/src/math/__tan.c", "musl/src/math/__tandf.c", "musl/src/math/tanh.c", diff --git a/test/libc.zig b/test/libc.zig @@ -137,6 +137,206 @@ pub fn addCases(cases: *tests.LibcContext) void { cases.addLibcTestCase("regression/uselocale-0.c", true, .{}); cases.addLibcTestCase("regression/wcsncpy-read-overflow.c", true, .{}); cases.addLibcTestCase("regression/wcsstr-false-negative.c", true, .{}); + + // cases.addLibcTestCase("math/acos.c", true, .{}); + // cases.addLibcTestCase("math/acosf.c", true, .{}); + // cases.addLibcTestCase("math/acosh.c", true, .{}); + cases.addLibcTestCase("math/acoshf.c", true, .{}); + // cases.addLibcTestCase("math/acoshl.c", true, .{}); + // cases.addLibcTestCase("math/acosl.c", true, .{}); + cases.addLibcTestCase("math/asin.c", true, .{}); + cases.addLibcTestCase("math/asinf.c", true, .{}); + // cases.addLibcTestCase("math/asinh.c", true, .{}); + cases.addLibcTestCase("math/asinhf.c", true, .{}); + // cases.addLibcTestCase("math/asinhl.c", true, .{}); + cases.addLibcTestCase("math/asinl.c", true, .{}); + cases.addLibcTestCase("math/atan.c", true, .{}); + // cases.addLibcTestCase("math/atan2.c", true, .{}); + // cases.addLibcTestCase("math/atan2f.c", true, .{}); + // cases.addLibcTestCase("math/atan2l.c", true, .{}); + cases.addLibcTestCase("math/atanf.c", true, .{}); + cases.addLibcTestCase("math/atanh.c", true, .{}); + cases.addLibcTestCase("math/atanhf.c", true, .{}); + cases.addLibcTestCase("math/atanhl.c", true, .{}); + cases.addLibcTestCase("math/atanl.c", true, .{}); + cases.addLibcTestCase("math/cbrt.c", true, .{}); + cases.addLibcTestCase("math/cbrtf.c", true, .{}); + cases.addLibcTestCase("math/cbrtl.c", true, .{}); + cases.addLibcTestCase("math/ceil.c", true, .{}); + cases.addLibcTestCase("math/ceilf.c", true, .{}); + cases.addLibcTestCase("math/ceill.c", true, .{}); + cases.addLibcTestCase("math/copysign.c", true, .{}); + cases.addLibcTestCase("math/copysignf.c", true, .{}); + cases.addLibcTestCase("math/copysignl.c", true, .{}); + cases.addLibcTestCase("math/cos.c", true, .{}); + cases.addLibcTestCase("math/cosf.c", true, .{}); + cases.addLibcTestCase("math/cosh.c", true, .{}); + cases.addLibcTestCase("math/coshf.c", true, .{}); + cases.addLibcTestCase("math/coshl.c", true, .{}); + cases.addLibcTestCase("math/cosl.c", true, .{}); + cases.addLibcTestCase("math/drem.c", true, .{}); + cases.addLibcTestCase("math/dremf.c", true, .{}); + cases.addLibcTestCase("math/erf.c", true, .{}); + cases.addLibcTestCase("math/erfc.c", true, .{}); + // cases.addLibcTestCase("math/erfcf.c", true, .{}); + cases.addLibcTestCase("math/erfcl.c", true, .{}); + cases.addLibcTestCase("math/erff.c", true, .{}); + cases.addLibcTestCase("math/erfl.c", true, .{}); + cases.addLibcTestCase("math/exp.c", true, .{}); + cases.addLibcTestCase("math/exp10.c", true, .{}); + cases.addLibcTestCase("math/exp10f.c", true, .{}); + cases.addLibcTestCase("math/exp10l.c", true, .{}); + cases.addLibcTestCase("math/exp2.c", true, .{}); + cases.addLibcTestCase("math/exp2f.c", true, .{}); + cases.addLibcTestCase("math/exp2l.c", true, .{}); + cases.addLibcTestCase("math/expf.c", true, .{}); + cases.addLibcTestCase("math/expl.c", true, .{}); + // cases.addLibcTestCase("math/expm1.c", true, .{}); + // cases.addLibcTestCase("math/expm1f.c", true, .{}); + // cases.addLibcTestCase("math/expm1l.c", true, .{}); + cases.addLibcTestCase("math/fabs.c", true, .{}); + cases.addLibcTestCase("math/fabsf.c", true, .{}); + cases.addLibcTestCase("math/fabsl.c", true, .{}); + // cases.addLibcTestCase("math/fdim.c", true, .{}); + // cases.addLibcTestCase("math/fdimf.c", true, .{}); + // cases.addLibcTestCase("math/fdiml.c", true, .{}); + cases.addLibcTestCase("math/fenv.c", true, .{}); + cases.addLibcTestCase("math/floor.c", true, .{}); + cases.addLibcTestCase("math/floorf.c", true, .{}); + cases.addLibcTestCase("math/floorl.c", true, .{}); + // cases.addLibcTestCase("math/fma.c", true, .{}); + // cases.addLibcTestCase("math/fmaf.c", true, .{}); + // cases.addLibcTestCase("math/fmal.c", true, .{}); + cases.addLibcTestCase("math/fmax.c", true, .{}); + cases.addLibcTestCase("math/fmaxf.c", true, .{}); + cases.addLibcTestCase("math/fmaxl.c", true, .{}); + cases.addLibcTestCase("math/fmin.c", true, .{}); + cases.addLibcTestCase("math/fminf.c", true, .{}); + cases.addLibcTestCase("math/fminl.c", true, .{}); + cases.addLibcTestCase("math/fmod.c", true, .{}); + cases.addLibcTestCase("math/fmodf.c", true, .{}); + cases.addLibcTestCase("math/fmodl.c", true, .{}); + cases.addLibcTestCase("math/fpclassify.c", true, .{}); + cases.addLibcTestCase("math/frexp.c", true, .{}); + cases.addLibcTestCase("math/frexpf.c", true, .{}); + cases.addLibcTestCase("math/frexpl.c", true, .{}); + cases.addLibcTestCase("math/hypot.c", true, .{}); + cases.addLibcTestCase("math/hypotf.c", true, .{}); + cases.addLibcTestCase("math/hypotl.c", true, .{}); + // cases.addLibcTestCase("math/ilogb.c", true, .{}); + // cases.addLibcTestCase("math/ilogbf.c", true, .{}); + // cases.addLibcTestCase("math/ilogbl.c", true, .{}); + cases.addLibcTestCase("math/isless.c", true, .{}); + // cases.addLibcTestCase("math/j0.c", true, .{}); + cases.addLibcTestCase("math/j0f.c", true, .{}); + cases.addLibcTestCase("math/j1.c", true, .{}); + cases.addLibcTestCase("math/j1f.c", true, .{}); + // cases.addLibcTestCase("math/jn.c", true, .{}); + // cases.addLibcTestCase("math/jnf.c", true, .{}); + cases.addLibcTestCase("math/ldexp.c", true, .{}); + cases.addLibcTestCase("math/ldexpf.c", true, .{}); + cases.addLibcTestCase("math/ldexpl.c", true, .{}); + // cases.addLibcTestCase("math/lgamma.c", true, .{}); + cases.addLibcTestCase("math/lgamma_r.c", true, .{}); + // cases.addLibcTestCase("math/lgammaf.c", true, .{}); + // cases.addLibcTestCase("math/lgammaf_r.c", true, .{}); + // cases.addLibcTestCase("math/lgammal.c", true, .{}); + cases.addLibcTestCase("math/lgammal_r.c", true, .{}); + // cases.addLibcTestCase("math/llrint.c", true, .{}); + // cases.addLibcTestCase("math/llrintf.c", true, .{}); + // cases.addLibcTestCase("math/llrintl.c", true, .{}); + // cases.addLibcTestCase("math/llround.c", true, .{}); + // cases.addLibcTestCase("math/llroundf.c", true, .{}); + // cases.addLibcTestCase("math/llroundl.c", true, .{}); + cases.addLibcTestCase("math/log.c", true, .{}); + cases.addLibcTestCase("math/log10.c", true, .{}); + cases.addLibcTestCase("math/log10f.c", true, .{}); + cases.addLibcTestCase("math/log10l.c", true, .{}); + // cases.addLibcTestCase("math/log1p.c", true, .{}); + // cases.addLibcTestCase("math/log1pf.c", true, .{}); + // cases.addLibcTestCase("math/log1pl.c", true, .{}); + cases.addLibcTestCase("math/log2.c", true, .{}); + cases.addLibcTestCase("math/log2f.c", true, .{}); + cases.addLibcTestCase("math/log2l.c", true, .{}); + cases.addLibcTestCase("math/logb.c", true, .{}); + cases.addLibcTestCase("math/logbf.c", true, .{}); + cases.addLibcTestCase("math/logbl.c", true, .{}); + cases.addLibcTestCase("math/logf.c", true, .{}); + cases.addLibcTestCase("math/logl.c", true, .{}); + cases.addLibcTestCase("math/lrint.c", true, .{}); + cases.addLibcTestCase("math/lrintf.c", true, .{}); + cases.addLibcTestCase("math/lrintl.c", true, .{}); + cases.addLibcTestCase("math/lround.c", true, .{}); + cases.addLibcTestCase("math/lroundf.c", true, .{}); + cases.addLibcTestCase("math/lroundl.c", true, .{}); + cases.addLibcTestCase("math/modf.c", true, .{}); + cases.addLibcTestCase("math/modff.c", true, .{}); + cases.addLibcTestCase("math/modfl.c", true, .{}); + // cases.addLibcTestCase("math/nearbyint.c", true, .{}); + cases.addLibcTestCase("math/nearbyintf.c", true, .{}); + // cases.addLibcTestCase("math/nearbyintl.c", true, .{}); + cases.addLibcTestCase("math/nextafter.c", true, .{}); + cases.addLibcTestCase("math/nextafterf.c", true, .{}); + cases.addLibcTestCase("math/nextafterl.c", true, .{}); + cases.addLibcTestCase("math/nexttoward.c", true, .{}); + cases.addLibcTestCase("math/nexttowardf.c", true, .{}); + cases.addLibcTestCase("math/nexttowardl.c", true, .{}); + // cases.addLibcTestCase("math/pow.c", true, .{}); + cases.addLibcTestCase("math/pow10.c", true, .{}); + cases.addLibcTestCase("math/pow10f.c", true, .{}); + cases.addLibcTestCase("math/pow10l.c", true, .{}); + // cases.addLibcTestCase("math/powf.c", true, .{}); + // cases.addLibcTestCase("math/powl.c", true, .{}); + cases.addLibcTestCase("math/remainder.c", true, .{}); + cases.addLibcTestCase("math/remainderf.c", true, .{}); + cases.addLibcTestCase("math/remainderl.c", true, .{}); + cases.addLibcTestCase("math/remquo.c", true, .{}); + cases.addLibcTestCase("math/remquof.c", true, .{}); + cases.addLibcTestCase("math/remquol.c", true, .{}); + // cases.addLibcTestCase("math/rint.c", true, .{}); + cases.addLibcTestCase("math/rintf.c", true, .{}); + // cases.addLibcTestCase("math/rintl.c", true, .{}); + // cases.addLibcTestCase("math/round.c", true, .{}); + // cases.addLibcTestCase("math/roundf.c", true, .{}); + // cases.addLibcTestCase("math/roundl.c", true, .{}); + cases.addLibcTestCase("math/scalb.c", true, .{}); + cases.addLibcTestCase("math/scalbf.c", true, .{}); + cases.addLibcTestCase("math/scalbln.c", true, .{}); + cases.addLibcTestCase("math/scalblnf.c", true, .{}); + cases.addLibcTestCase("math/scalblnl.c", true, .{}); + cases.addLibcTestCase("math/scalbn.c", true, .{}); + cases.addLibcTestCase("math/scalbnf.c", true, .{}); + cases.addLibcTestCase("math/scalbnl.c", true, .{}); + cases.addLibcTestCase("math/sin.c", true, .{}); + cases.addLibcTestCase("math/sincos.c", true, .{}); + cases.addLibcTestCase("math/sincosf.c", true, .{}); + cases.addLibcTestCase("math/sincosl.c", true, .{}); + cases.addLibcTestCase("math/sinf.c", true, .{}); + // cases.addLibcTestCase("math/sinh.c", true, .{}); + cases.addLibcTestCase("math/sinhf.c", true, .{}); + // cases.addLibcTestCase("math/sinhl.c", true, .{}); + cases.addLibcTestCase("math/sinl.c", true, .{}); + cases.addLibcTestCase("math/sqrt.c", true, .{}); + cases.addLibcTestCase("math/sqrtf.c", true, .{}); + cases.addLibcTestCase("math/sqrtl.c", true, .{}); + cases.addLibcTestCase("math/tan.c", true, .{}); + cases.addLibcTestCase("math/tanf.c", true, .{}); + cases.addLibcTestCase("math/tanh.c", true, .{}); + cases.addLibcTestCase("math/tanhf.c", true, .{}); + cases.addLibcTestCase("math/tanhl.c", true, .{}); + cases.addLibcTestCase("math/tanl.c", true, .{}); + // cases.addLibcTestCase("math/tgamma.c", true, .{}); + // cases.addLibcTestCase("math/tgammaf.c", true, .{}); + // cases.addLibcTestCase("math/tgammal.c", true, .{}); + cases.addLibcTestCase("math/trunc.c", true, .{}); + cases.addLibcTestCase("math/truncf.c", true, .{}); + cases.addLibcTestCase("math/truncl.c", true, .{}); + // cases.addLibcTestCase("math/y0.c", true, .{}); + // cases.addLibcTestCase("math/y0f.c", true, .{}); + // cases.addLibcTestCase("math/y1.c", true, .{}); + // cases.addLibcTestCase("math/y1f.c", true, .{}); + // cases.addLibcTestCase("math/yn.c", true, .{}); + // cases.addLibcTestCase("math/ynf.c", true, .{}); } const std = @import("std"); diff --git a/test/src/Libc.zig b/test/src/Libc.zig @@ -60,10 +60,10 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void { .link_libc = true, }); - var libtest_c_source_files: []const []const u8 = &.{ "print.c", "rand.c", "setrlim.c", "memfill.c", "vmfill.c", "fdfill.c", "utf8.c" }; + var libtest_c_source_files: []const []const u8 = &.{ "print.c", "rand.c", "mtest.c", "setrlim.c", "memfill.c", "vmfill.c", "fdfill.c", "utf8.c" }; libtest_mod.addCSourceFiles(.{ .root = common, - .files = libtest_c_source_files[0..if (target.result.isMuslLibC()) 7 else 2], + .files = libtest_c_source_files[0..if (target.result.isMuslLibC()) 8 else 3], .flags = &.{"-fno-builtin"}, }); diff --git a/test/tests.zig b/test/tests.zig @@ -2873,11 +2873,12 @@ const libc_targets: []const std.Target.Query = &.{ .os_tag = .linux, .abi = .musl, }, - .{ - .cpu_arch = .loongarch64, - .os_tag = .linux, - .abi = .muslsf, - }, + // Macros like FE_INVALID are defined by musl, but they shouldn't. + // .{ + // .cpu_arch = .loongarch64, + // .os_tag = .linux, + // .abi = .muslsf, + // }, // .{ // .cpu_arch = .mips, // .os_tag = .linux,