mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
zig libc: export floorl and ceill
needed since self-hosted now contains calls to `@divFloor` and `@divTrunc` for 128-bit floats.
This commit is contained in:
parent
d0dceae736
commit
86b9280963
@ -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)),
|
||||
};
|
||||
}
|
||||
|
||||
@ -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)),
|
||||
};
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user