authorgravatar for jcmoyer32@gmail.comJ.C. Moyer <jcmoyer32@gmail.com> 2021-11-16 21:56:55-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-21 16:44:21-05:00
log939f51aebba982259628f6255a0b0b0ec2d9c99a
tree81824d6aba532e7498ecb0b92bb3011eb3caf761
parent12140ead432c24ed68600b95c2252c7619b5d658

compiler_rt: export floorf, floor, and floorl

This fixes a stage1 linker error when compiling with VS2022 on Windows.

2 files changed, 21 insertions(+), 16 deletions(-)

lib/std/special/c_stage1.zig-15
......@@ -639,21 +639,6 @@ export fn fmod(x: f64, y: f64) f64 {
639639 return generic_fmod(f64, x, y);
640640}
641641
642// TODO add intrinsics for these (and probably the double version too)
643// and have the math stuff use the intrinsic. same as @mod and @rem
644export fn floorf(x: f32) f32 {
645 return math.floor(x);
646}
647export fn floor(x: f64) f64 {
648 return math.floor(x);
649}
650export fn floorl(x: c_longdouble) c_longdouble {
651 if (!long_double_is_f128) {
652 @panic("TODO implement this");
653 }
654 return math.floor(x);
655}
656
657642export fn ceilf(x: f32) f32 {
658643 return math.ceil(x);
659644}
lib/std/special/compiler_rt.zig+21-1
......@@ -630,11 +630,31 @@ comptime {
630630 _ = @import("compiler_rt/atomics.zig");
631631
632632 @export(fmaq, .{ .name = "fmaq", .linkage = linkage });
633 @export(floorf, .{ .name = "floorf", .linkage = linkage });
634 @export(floor, .{ .name = "floor", .linkage = linkage });
635 @export(floorl, .{ .name = "floorl", .linkage = linkage });
633636 }
634637}
635638
639const math = std.math;
640
636641fn fmaq(a: f128, b: f128, c: f128) callconv(.C) f128 {
637 return std.math.fma(f128, a, b, c);
642 return math.fma(f128, a, b, c);
643}
644
645// TODO add intrinsics for these (and probably the double version too)
646// and have the math stuff use the intrinsic. same as @mod and @rem
647fn floorf(x: f32) callconv(.C) f32 {
648 return math.floor(x);
649}
650fn floor(x: f64) callconv(.C) f64 {
651 return math.floor(x);
652}
653fn floorl(x: c_longdouble) callconv(.C) c_longdouble {
654 if (!long_double_is_f128) {
655 @panic("TODO implement this");
656 }
657 return math.floor(x);
638658}
639659
640660// Avoid dragging in the runtime safety mechanisms into this .o file,