mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
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 bigIntFromFloat = @import("./int_from_float.zig").bigIntFromFloat;
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const common = @import("common.zig");
|
||||
const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
@@ -8,6 +9,7 @@ comptime {
|
||||
@export(&__fixdfei, .{ .name = "__fixdfei", .linkage = common.linkage, .visibility = common.visibility });
|
||||
}
|
||||
|
||||
pub fn __fixdfei(r: [*]u32, bits: usize, a: f64) callconv(.c) void {
|
||||
return bigIntFromFloat(.signed, r[0 .. divCeil(usize, bits, 32) catch unreachable], a);
|
||||
pub fn __fixdfei(r: [*]u8, bits: usize, a: f64) callconv(.c) void {
|
||||
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
|
||||
return bigIntFromFloat(.signed, @ptrCast(@alignCast(r[0..byte_size])), a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user