| author | |
| committer | |
| log | 6cdd576d4176c2581f796c2066ca0f92bda03c9e |
| tree | ac7bdf96f5fdb765ef438d8a92bee315f34975c7 |
| parent | 28ae5d4158b084d17e55e73aec4c37e22885bd78 |
5 files changed, 15 insertions(+), 13 deletions(-)
lib/c/math.zig+14| ... | ... | @@ -59,6 +59,7 @@ comptime { |
| 59 | 59 | symbol(&cosh, "cosh"); |
| 60 | 60 | symbol(&exp10, "exp10"); |
| 61 | 61 | symbol(&exp10f, "exp10f"); |
| 62 | symbol(&fdim, "fdim"); | |
| 62 | 63 | symbol(&hypot, "hypot"); |
| 63 | 64 | symbol(&modf, "modf"); |
| 64 | 65 | symbol(&pow, "pow"); |
| ... | ... | @@ -147,6 +148,19 @@ fn exp10f(x: f32) callconv(.c) f32 { |
| 147 | 148 | return math.pow(f32, 10.0, x); |
| 148 | 149 | } |
| 149 | 150 | |
| 151 | fn fdim(x: f64, y: f64) callconv(.c) f64 { | |
| 152 | if (math.isNan(x)) { | |
| 153 | return x; | |
| 154 | } | |
| 155 | if (math.isNan(y)) { | |
| 156 | return y; | |
| 157 | } | |
| 158 | if (x > y) { | |
| 159 | return x - y; | |
| 160 | } | |
| 161 | return 0; | |
| 162 | } | |
| 163 | ||
| 150 | 164 | fn hypot(x: f64, y: f64) callconv(.c) f64 { |
| 151 | 165 | return math.hypot(x, y); |
| 152 | 166 | } |
lib/libc/musl/src/math/fdim.c deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | #include <math.h> | |
| 2 | ||
| 3 | double fdim(double x, double y) | |
| 4 | { | |
| 5 | 	if (isnan(x)) | |
| 6 | 		return x; | |
| 7 | 	if (isnan(y)) | |
| 8 | 		return y; | |
| 9 | 	return x > y ? x - y : 0; | |
| 10 | } |
src/libs/musl.zig-1| ... | ... | @@ -830,7 +830,6 @@ const src_files = [_][]const u8{ |
| 830 | 830 | "musl/src/math/expm1l.c", |
| 831 | 831 | "musl/src/math/__expo2.c", |
| 832 | 832 | "musl/src/math/__expo2f.c", |
| 833 | "musl/src/math/fdim.c", | |
| 834 | 833 | "musl/src/math/fdimf.c", |
| 835 | 834 | "musl/src/math/fdiml.c", |
| 836 | 835 | "musl/src/math/finite.c", |
src/libs/wasi_libc.zig-1| ... | ... | @@ -695,7 +695,6 @@ const libc_top_half_src_files = [_][]const u8{ |
| 695 | 695 | "musl/src/math/expm1.c", |
| 696 | 696 | "musl/src/math/expm1f.c", |
| 697 | 697 | "musl/src/math/expm1l.c", |
| 698 | "musl/src/math/fdim.c", | |
| 699 | 698 | "musl/src/math/fdimf.c", |
| 700 | 699 | "musl/src/math/fdiml.c", |
| 701 | 700 | "musl/src/math/finite.c", |
test/libc.zig+1-1| ... | ... | @@ -197,7 +197,7 @@ pub fn addCases(cases: *tests.LibcContext) void { |
| 197 | 197 | cases.addLibcTestCase("math/fabs.c", true, .{}); |
| 198 | 198 | cases.addLibcTestCase("math/fabsf.c", true, .{}); |
| 199 | 199 | cases.addLibcTestCase("math/fabsl.c", true, .{}); |
| 200 | // cases.addLibcTestCase("math/fdim.c", true, .{}); | |
| 200 | cases.addLibcTestCase("math/fdim.c", true, .{}); | |
| 201 | 201 | // cases.addLibcTestCase("math/fdimf.c", true, .{}); |
| 202 | 202 | // cases.addLibcTestCase("math/fdiml.c", true, .{}); |
| 203 | 203 | cases.addLibcTestCase("math/fenv.c", true, .{}); |