diff --git a/lib/std/math/ceil.zig b/lib/std/math/ceil.zig index fbac256166..cf3adcf5b5 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 c5ddb9e144..d6761ba77e 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 cd2d833c2d..c0323b1ae7 100644 --- a/lib/std/special/c_stage1.zig +++ b/lib/std/special/c_stage1.zig @@ -644,32 +644,41 @@ export fn fmod(x: f64, y: f64) f64 { export fn floorf(x: f32) f32 { return math.floor(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 floor(x: f64) f64 { - return math.floor(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); + 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 fmaf(a: f32, b: f32, c: f32) f32 { - return math.fma(f32, 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 {