aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler_rt/fixhfti.zig
blob: b6774968ddc377896606479ee2f410812881194a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;

pub const panic = common.panic;

comptime {
    if (common.want_windows_v2u64_abi) {
        @export(__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage });
    } else {
        @export(__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage });
    }
}

pub fn __fixhfti(a: f16) callconv(.C) i128 {
    return floatToInt(i128, a);
}

const v2u64 = @Vector(2, u64);

fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
    return @bitCast(v2u64, floatToInt(i128, a));
}