diff --git a/lib/std/math/ceil.zig b/lib/std/math/ceil.zig index fbac2561662d36299be1bcf17ebfa741670e1ec4..cf3adcf5b572652ab7833ea95092e0ae4ed14757 100644 --- a/lib/std/math/ceil.zig +++ b/lib/std/math/ceil.zig @@ -20,6 +20,10 @@ pub fn ceil(x: anytype) @TypeOf(x) { f32 => ceil32(x), f64 => ceil64(x), f128 => ceil128(x), + + // TODO this is not correct for some targets + c_longdouble => @floatCast(c_longdouble, ceil128(x)), + else => @compileError("ceil not implemented for " ++ @typeName(T)), }; } diff --git a/lib/std/math/floor.zig b/lib/std/math/floor.zig index c5ddb9e1441c09ee9f3a35cb3df57fb350d2e88d..d6761ba77e7ea949655eabc738a46cd7cfe0a4a6 100644 --- a/lib/std/math/floor.zig +++ b/lib/std/math/floor.zig @@ -21,6 +21,10 @@ pub fn floor(x: anytype) @TypeOf(x) { f32 => floor32(x), f64 => floor64(x), f128 => floor128(x), + + // TODO this is not correct for some targets + c_longdouble => @floatCast(c_longdouble, floor128(x)), + else => @compileError("floor not implemented for " ++ @typeName(T)), }; } diff --git a/lib/std/special/c_stage1.zig b/lib/std/special/c_stage1.zig index cd2d833c2d55b5fd502ebce531885e52ede260a7..c0323b1ae72d6c913ec2dc93db0bad0b724f8e84 100644 --- a/lib/std/special/c_stage1.zig +++ b/lib/std/special/c_stage1.zig @@ -644,34 +644,43 @@ export fn fmod(x: f64, y: f64) f64 { export fn floorf(x: f32) f32 { return math.floor(x); } - -export fn ceilf(x: f32) f32 { - return math.ceil(x); -} - export fn floor(x: f64) f64 { return math.floor(x); } +export fn floorl(x: c_longdouble) c_longdouble { + if (!long_double_is_f128) { + @panic("TODO implement this"); + } + return math.floor(x); +} +export fn ceilf(x: f32) f32 { + return math.ceil(x); +} export fn ceil(x: f64) f64 { return math.ceil(x); } - -export fn fmal(a: c_longdouble, b: c_longdouble, c: c_longdouble) c_longdouble { +export fn ceill(x: c_longdouble) c_longdouble { if (!long_double_is_f128) { @panic("TODO implement this"); } - return math.fma(c_longdouble, a, b, c); -} - -export fn fma(a: f64, b: f64, c: f64) f64 { - return math.fma(f64, a, b, c); + return math.ceil(x); } export fn fmaf(a: f32, b: f32, c: f32) f32 { return math.fma(f32, a, b, c); } +export fn fma(a: f64, b: f64, c: f64) f64 { + return math.fma(f64, a, b, c); +} +export fn fmal(a: c_longdouble, b: c_longdouble, c: c_longdouble) c_longdouble { + if (!long_double_is_f128) { + @panic("TODO implement this"); + } + return math.fma(c_longdouble, a, b, c); +} + export fn sin(a: f64) f64 { return math.sin(a); }