mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
fix: make compiler_rt and std.Io.Writer compile on 16-bit platforms.
This commit is contained in:
parent
914acf13cb
commit
55c0693c4a
@ -74,7 +74,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul
|
||||
const parts = math.frexp(a);
|
||||
const significand_bits_adjusted_to_handle_smin = @as(i32, significand_bits) +
|
||||
@intFromBool(signedness == .signed and parts.exponent == 32 * result.len);
|
||||
const exponent = @max(parts.exponent - significand_bits_adjusted_to_handle_smin, 0);
|
||||
const exponent: usize = @intCast(@max(parts.exponent - significand_bits_adjusted_to_handle_smin, 0));
|
||||
const int: I = @intFromFloat(switch (exponent) {
|
||||
0 => a,
|
||||
else => math.ldexp(parts.significand, significand_bits_adjusted_to_handle_smin),
|
||||
|
||||
@ -604,7 +604,7 @@ pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void {
|
||||
@compileError("32 arguments max are supported per format call");
|
||||
}
|
||||
|
||||
@setEvalBranchQuota(fmt.len * 1000);
|
||||
@setEvalBranchQuota(@as(comptime_int, fmt.len) * 1000); // NOTE: We're upcasting as 16-bit usize overflows.
|
||||
comptime var arg_state: std.fmt.ArgState = .{ .args_len = fields_info.len };
|
||||
comptime var i = 0;
|
||||
comptime var literal: []const u8 = "";
|
||||
|
||||
@ -4634,6 +4634,8 @@ pub const TEB = extern struct {
|
||||
};
|
||||
|
||||
comptime {
|
||||
// XXX: Without this check we cannot use `std.Io.Writer` on 16-bit platforms. `std.fmt.bufPrint` will hit the unreachable in `PEB.GdiHandleBuffer` without this guard.
|
||||
if (builtin.os.tag == .windows) {
|
||||
// Offsets taken from WinDbg info and Geoff Chappell[1] (RIP)
|
||||
// [1]: https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm
|
||||
assert(@offsetOf(TEB, "NtTib") == 0x00);
|
||||
@ -4654,6 +4656,7 @@ comptime {
|
||||
assert(@offsetOf(TEB, "LastErrorValue") == 0x68);
|
||||
assert(@offsetOf(TEB, "TlsSlots") == 0x1480);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const EXCEPTION_REGISTRATION_RECORD = extern struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user