Skip to content

Commit ff1282e

Browse files
committed
x86_64: implement union access
1 parent 390efcf commit ff1282e

File tree

4 files changed

+284
-69
lines changed

4 files changed

+284
-69
lines changed

lib/std/debug.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub const Coverage = @import("debug/Coverage.zig");
2323

2424
pub const FormattedPanic = @import("debug/FormattedPanic.zig");
2525
pub const SimplePanic = @import("debug/SimplePanic.zig");
26+
pub const NoPanic = @import("debug/NoPanic.zig");
2627

2728
/// Unresolved source locations can be represented with a single `usize` that
2829
/// corresponds to a virtual memory address of the program counter. Combined

lib/std/debug/NoPanic.zig

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//! This namespace can be used with `pub const Panic = std.debug.NoPanic;` in the root file.
2+
//! It emits as little code as possible, for testing purposes.
3+
//!
4+
//! For a functional alternative, see `std.debug.FormattedPanic`.
5+
6+
const std = @import("../std.zig");
7+
8+
pub fn call(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
9+
@branchHint(.cold);
10+
@trap();
11+
}
12+
13+
pub inline fn sentinelMismatch(_: anytype, _: anytype) noreturn {
14+
@branchHint(.cold);
15+
@trap();
16+
}
17+
18+
pub inline fn unwrapError(_: ?*std.builtin.StackTrace, _: anyerror) noreturn {
19+
@branchHint(.cold);
20+
@trap();
21+
}
22+
23+
pub inline fn outOfBounds(_: usize, _: usize) noreturn {
24+
@branchHint(.cold);
25+
@trap();
26+
}
27+
28+
pub inline fn startGreaterThanEnd(_: usize, _: usize) noreturn {
29+
@branchHint(.cold);
30+
@trap();
31+
}
32+
33+
pub inline fn inactiveUnionField(_: anytype, _: anytype) noreturn {
34+
@branchHint(.cold);
35+
@trap();
36+
}
37+
38+
pub const messages = struct {
39+
pub const reached_unreachable = "";
40+
pub const unwrap_null = "";
41+
pub const cast_to_null = "";
42+
pub const incorrect_alignment = "";
43+
pub const invalid_error_code = "";
44+
pub const cast_truncated_data = "";
45+
pub const negative_to_unsigned = "";
46+
pub const integer_overflow = "";
47+
pub const shl_overflow = "";
48+
pub const shr_overflow = "";
49+
pub const divide_by_zero = "";
50+
pub const exact_division_remainder = "";
51+
pub const integer_part_out_of_bounds = "";
52+
pub const corrupt_switch = "";
53+
pub const shift_rhs_too_big = "";
54+
pub const invalid_enum_value = "";
55+
pub const for_len_mismatch = "";
56+
pub const memcpy_len_mismatch = "";
57+
pub const memcpy_alias = "";
58+
pub const noreturn_returned = "";
59+
};

0 commit comments

Comments
 (0)