compiler-rt: compute correct integer sizes from bits at runtime
Also, accepting `align(1)` pointers ensures that the alignment is safety checked rather than assumed.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const divCeil = @import("std").math.divCeil;
|
||||
const common = @import("./common.zig");
|
||||
const floatFromBigInt = @import("./float_from_int.zig").floatFromBigInt;
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const common = @import("common.zig");
|
||||
const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
@@ -8,6 +9,7 @@ comptime {
|
||||
@export(&__floatuneitf, .{ .name = "__floatuneitf", .linkage = common.linkage, .visibility = common.visibility });
|
||||
}
|
||||
|
||||
pub fn __floatuneitf(a: [*]const u32, bits: usize) callconv(.c) f128 {
|
||||
return floatFromBigInt(f128, .unsigned, a[0 .. divCeil(usize, bits, 32) catch unreachable]);
|
||||
pub fn __floatuneitf(a: [*]const u8, bits: usize) callconv(.c) f128 {
|
||||
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
|
||||
return floatFromBigInt(f128, .unsigned, @ptrCast(@alignCast(a[0..byte_size])));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user