mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
zig libc: export fdiml and fdimf (#31759)
Exports `fdiml` and `fdimf` in zig libc and removes from from musl and mingw libc. Contributes to: https://codeberg.org/ziglang/zig/issues/30978 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31759 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Co-authored-by: badayvedat <badayvedat@gmail.com> Co-committed-by: badayvedat <badayvedat@gmail.com>
This commit is contained in:
committed by
Andrew Kelley
parent
bf40264941
commit
a05a25e2bb
+20
-7
@@ -45,6 +45,7 @@ comptime {
|
||||
if ((builtin.target.isMinGW() and @sizeOf(f64) != @sizeOf(c_longdouble)) or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
|
||||
symbol(&atanl, "atanl");
|
||||
symbol(©signl, "copysignl");
|
||||
symbol(&fdiml, "fdiml");
|
||||
symbol(&nanl, "nanl");
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ comptime {
|
||||
symbol(&exp10, "exp10");
|
||||
symbol(&exp10f, "exp10f");
|
||||
symbol(&fdim, "fdim");
|
||||
symbol(&fdimf, "fdimf");
|
||||
symbol(&finite, "finite");
|
||||
symbol(&finitef, "finitef");
|
||||
symbol(&frexp, "frexp");
|
||||
@@ -160,19 +162,30 @@ fn exp10f(x: f32) callconv(.c) f32 {
|
||||
return math.pow(f32, 10.0, x);
|
||||
}
|
||||
|
||||
fn fdim(x: f64, y: f64) callconv(.c) f64 {
|
||||
if (math.isNan(x)) {
|
||||
fn fdimGeneric(comptime T: type, x: T, y: T) T {
|
||||
if (math.isNan(x))
|
||||
return x;
|
||||
}
|
||||
if (math.isNan(y)) {
|
||||
|
||||
if (math.isNan(y))
|
||||
return y;
|
||||
}
|
||||
if (x > y) {
|
||||
|
||||
if (x > y)
|
||||
return x - y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn fdim(x: f64, y: f64) callconv(.c) f64 {
|
||||
return fdimGeneric(f64, x, y);
|
||||
}
|
||||
|
||||
fn fdimf(x: f32, y: f32) callconv(.c) f32 {
|
||||
return fdimGeneric(f32, x, y);
|
||||
}
|
||||
|
||||
fn fdiml(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
|
||||
return fdimGeneric(c_longdouble, x, y);
|
||||
}
|
||||
|
||||
fn finite(x: f64) callconv(.c) c_int {
|
||||
return if (math.isFinite(x)) 1 else 0;
|
||||
}
|
||||
|
||||
Vendored
-24
@@ -1,24 +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 <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
fdiml (long double x, long double y)
|
||||
{
|
||||
int cx = fpclassify (x), cy = fpclassify (y);
|
||||
long double r;
|
||||
|
||||
if (cx == FP_NAN || cy == FP_NAN
|
||||
|| (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
|
||||
return x - y; /* Take care invalid flag is raised. */
|
||||
if (x <= y)
|
||||
return 0.0;
|
||||
r = x - y;
|
||||
if (fpclassify (r) == FP_INFINITE)
|
||||
errno = ERANGE;
|
||||
return r;
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
float fdimf(float x, float y)
|
||||
{
|
||||
if (isnan(x))
|
||||
return x;
|
||||
if (isnan(y))
|
||||
return y;
|
||||
return x > y ? x - y : 0;
|
||||
}
|
||||
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
||||
long double fdiml(long double x, long double y)
|
||||
{
|
||||
return fdim(x, y);
|
||||
}
|
||||
#else
|
||||
long double fdiml(long double x, long double y)
|
||||
{
|
||||
if (isnan(x))
|
||||
return x;
|
||||
if (isnan(y))
|
||||
return y;
|
||||
return x > y ? x - y : 0;
|
||||
}
|
||||
#endif
|
||||
@@ -850,7 +850,6 @@ const mingw32_x86_src = [_][]const u8{
|
||||
"complex" ++ path.sep_str ++ "ctanl.c",
|
||||
"math" ++ path.sep_str ++ "cbrtl.c",
|
||||
"math" ++ path.sep_str ++ "erfl.c",
|
||||
"math" ++ path.sep_str ++ "fdiml.c",
|
||||
"math" ++ path.sep_str ++ "fmal.c",
|
||||
"math" ++ path.sep_str ++ "llrintl.c",
|
||||
"math" ++ path.sep_str ++ "llroundl.c",
|
||||
|
||||
@@ -823,8 +823,6 @@ const src_files = [_][]const u8{
|
||||
"musl/src/math/expm1l.c",
|
||||
"musl/src/math/__expo2.c",
|
||||
"musl/src/math/__expo2f.c",
|
||||
"musl/src/math/fdimf.c",
|
||||
"musl/src/math/fdiml.c",
|
||||
"musl/src/math/fma.c",
|
||||
"musl/src/math/fmaf.c",
|
||||
"musl/src/math/fmal.c",
|
||||
|
||||
@@ -692,8 +692,6 @@ const libc_top_half_src_files = [_][]const u8{
|
||||
"musl/src/math/expm1.c",
|
||||
"musl/src/math/expm1f.c",
|
||||
"musl/src/math/expm1l.c",
|
||||
"musl/src/math/fdimf.c",
|
||||
"musl/src/math/fdiml.c",
|
||||
"musl/src/math/fma.c",
|
||||
"musl/src/math/fmaf.c",
|
||||
"musl/src/math/ilogb.c",
|
||||
|
||||
+2
-2
@@ -198,8 +198,8 @@ pub fn addCases(cases: *tests.LibcContext) void {
|
||||
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/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, .{});
|
||||
|
||||
Reference in New Issue
Block a user