mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
freestanding libc: include roundl
This commit is contained in:
parent
547e6f6ee1
commit
2a50a4629b
2 changed files with 13 additions and 1 deletions
|
|
@ -20,6 +20,10 @@ pub fn round(x: anytype) @TypeOf(x) {
|
|||
f32 => round32(x),
|
||||
f64 => round64(x),
|
||||
f128 => round128(x),
|
||||
|
||||
// TODO this is not correct for some targets
|
||||
c_longdouble => @floatCast(c_longdouble, round128(x)),
|
||||
|
||||
else => @compileError("round not implemented for " ++ @typeName(T)),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ comptime {
|
|||
|
||||
@export(round, .{ .name = "round", .linkage = .Strong });
|
||||
@export(roundf, .{ .name = "roundf", .linkage = .Strong });
|
||||
@export(roundl, .{ .name = "roundl", .linkage = .Strong });
|
||||
|
||||
@export(fmin, .{ .name = "fmin", .linkage = .Strong });
|
||||
@export(fminf, .{ .name = "fminf", .linkage = .Strong });
|
||||
|
|
@ -575,11 +576,18 @@ fn fabsf(a: f32) callconv(.C) f32 {
|
|||
return math.fabs(a);
|
||||
}
|
||||
|
||||
fn roundf(a: f32) callconv(.C) f32 {
|
||||
return math.round(a);
|
||||
}
|
||||
|
||||
fn round(a: f64) callconv(.C) f64 {
|
||||
return math.round(a);
|
||||
}
|
||||
|
||||
fn roundf(a: f32) callconv(.C) f32 {
|
||||
fn roundl(a: c_longdouble) callconv(.C) c_longdouble {
|
||||
if (!long_double_is_f128) {
|
||||
@panic("TODO implement this");
|
||||
}
|
||||
return math.round(a);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue