diff --git a/build.zig.zon b/build.zig.zon index 9e349a9..3d826c6 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .@"zig-network" = .{ - .url = "https://github.com/MasterQ32/zig-network/archive/86c315be67c7567195cc426615d81202a39bbb91.tar.gz", - .hash = "1220746fef79fb9774d76a0a5d746ccf30cfc847bce4a3a7388c3451817b7ab92869", + .url = "https://github.com/MasterQ32/zig-network/archive/7b5f76ea09626b96755c027bf4bd5b7e45297027.tar.gz", + .hash = "122090e7cb4459c2224399a45c56f47462733b919aa547c96b8c14ee705bfa22976e", }, }, } diff --git a/src/Packet.zig b/src/Packet.zig index e628b26..e2b77c9 100644 --- a/src/Packet.zig +++ b/src/Packet.zig @@ -293,7 +293,7 @@ pub fn checksum(input: []const u8) u8 { var sum: usize = 0; for (input) |char| sum += char; - return @truncate(u8, sum); + return @truncate(sum); } fn verify(input: []const u8, chksum: u8) bool { diff --git a/src/lib.zig b/src/lib.zig index d039419..1b9f2c3 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -35,35 +35,33 @@ pub const Emulator = struct { if (ptr_info != .Pointer) @compileError("ptr must be a pointer"); if (ptr_info.Pointer.size != .One) @compileError("ptr must be a single-item pointer"); - const alignment = ptr_info.Pointer.alignment; - const gen = struct { pub fn readImpl(pointer: *anyopaque, addr: u32) u8 { - const self = @ptrCast(Ptr, @alignCast(alignment, pointer)); + const self: Ptr = @ptrCast(@alignCast(pointer)); return @call(.always_inline, ptr_info.Pointer.child.read, .{ self, addr }); } pub fn writeImpl(pointer: *anyopaque, addr: u32, value: u8) void { - const self = @ptrCast(Ptr, @alignCast(alignment, pointer)); + const self: Ptr = @ptrCast(@alignCast(pointer)); return @call(.always_inline, ptr_info.Pointer.child.write, .{ self, addr, value }); } pub fn registersImpl(pointer: *anyopaque) *[16]u32 { - const self = @ptrCast(Ptr, @alignCast(alignment, pointer)); + const self: Ptr = @ptrCast(@alignCast(pointer)); return @call(.always_inline, ptr_info.Pointer.child.registers, .{self}); } pub fn cpsrImpl(pointer: *anyopaque) u32 { - const self = @ptrCast(Ptr, @alignCast(alignment, pointer)); + const self: Ptr = @ptrCast(@alignCast(pointer)); return @call(.always_inline, ptr_info.Pointer.child.cpsr, .{self}); } pub fn stepImpl(pointer: *anyopaque) void { - const self = @ptrCast(Ptr, @alignCast(alignment, pointer)); + const self: Ptr = @ptrCast(@alignCast(pointer)); return @call(.always_inline, ptr_info.Pointer.child.step, .{self}); }