authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-08 23:30:23+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-09 10:28:48+01:00
loge588e3873cdb4a7f8e03085d83453f9f3d5e36a7
tree449f1c9219b875bac6340fed6b875dc7553ebb0a
parentb28e9e42e07ae553fc35fb47c1ace619405c2b5c

stage2: export trunc, truncf and truncl


1 files changed, 20 insertions(+), 0 deletions(-)

lib/std/special/c.zig+20
......@@ -6,7 +6,9 @@
66
77const std = @import("std");
88const builtin = @import("builtin");
9const math = std.math;
910const native_os = builtin.os.tag;
11const long_double_is_f128 = builtin.target.longDoubleIsF128();
1012
1113comptime {
1214 // When the self-hosted compiler is further along, all the logic from c_stage1.zig will
......@@ -15,6 +17,9 @@ comptime {
1517 if (builtin.zig_backend != .stage1) {
1618 @export(memset, .{ .name = "memset", .linkage = .Strong });
1719 @export(memcpy, .{ .name = "memcpy", .linkage = .Strong });
20 @export(trunc, .{ .name = "trunc", .linkage = .Strong });
21 @export(truncf, .{ .name = "truncf", .linkage = .Strong });
22 @export(truncl, .{ .name = "truncl", .linkage = .Strong });
1823 } else {
1924 _ = @import("c_stage1.zig");
2025 }
......@@ -74,3 +79,18 @@ fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, len: usize) callconv(
7479
7580 return dest;
7681}
82
83fn trunc(a: f64) f64 {
84 return math.trunc(a);
85}
86
87fn truncf(a: f32) f32 {
88 return math.trunc(a);
89}
90
91fn truncl(a: c_longdouble) c_longdouble {
92 if (!long_double_is_f128) {
93 @panic("TODO implement this");
94 }
95 return math.trunc(a);
96}