Skip to content

compiler_rt: export floorl #10163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions lib/std/special/c_stage1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -639,21 +639,6 @@ export fn fmod(x: f64, y: f64) f64 {
return generic_fmod(f64, x, y);
}

// TODO add intrinsics for these (and probably the double version too)
// and have the math stuff use the intrinsic. same as @mod and @rem
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);
}
Expand Down
22 changes: 21 additions & 1 deletion lib/std/special/compiler_rt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,31 @@ comptime {
_ = @import("compiler_rt/atomics.zig");

@export(fmaq, .{ .name = "fmaq", .linkage = linkage });
@export(floorf, .{ .name = "floorf", .linkage = linkage });
@export(floor, .{ .name = "floor", .linkage = linkage });
@export(floorl, .{ .name = "floorl", .linkage = linkage });
}
}

const math = std.math;

fn fmaq(a: f128, b: f128, c: f128) callconv(.C) f128 {
return std.math.fma(f128, a, b, c);
return math.fma(f128, a, b, c);
}

// TODO add intrinsics for these (and probably the double version too)
// and have the math stuff use the intrinsic. same as @mod and @rem
fn floorf(x: f32) callconv(.C) f32 {
return math.floor(x);
}
fn floor(x: f64) callconv(.C) f64 {
return math.floor(x);
}
fn floorl(x: c_longdouble) callconv(.C) c_longdouble {
if (!long_double_is_f128) {
@panic("TODO implement this");
}
return math.floor(x);
}

// Avoid dragging in the runtime safety mechanisms into this .o file,
Expand Down