zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 496313a1bd4e8a4663ea99942d179a52b57e04e6 (tree)
parent 87448654256d334e1d5877736a9747de67b7eedf
Author: George Huebner <george@feyor.sh>
Date:   Mon, 25 Aug 2025 08:26:12 -0500

bpf: use bitCast instead of intCast in ld_imm_impl

Any 32 bit immediate is allowed in a BPF instruction, including those
greater than the largest positive i32 value.

Diffstat:
Mlib/std/os/linux/bpf.zig | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig @@ -642,7 +642,7 @@ pub const Insn = packed struct { .dst = @intFromEnum(dst), .src = @intFromEnum(src), .off = 0, - .imm = @as(i32, @intCast(@as(u32, @truncate(imm)))), + .imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))), }; } @@ -652,7 +652,7 @@ pub const Insn = packed struct { .dst = 0, .src = 0, .off = 0, - .imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))), + .imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))), }; }