| ... | @@ -1163,11 +1163,7 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia | ... | @@ -1163,11 +1163,7 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1163 | .@"struct" => |info| switch (info.layout) { | 1163 | .@"struct" => |info| switch (info.layout) { |
| 1164 | .auto => @compileError("ill-defined memory layout"), | 1164 | .auto => @compileError("ill-defined memory layout"), |
| 1165 | .@"extern" => { | 1165 | .@"extern" => { |
| 1166 | // This code works around https://github.com/ziglang/zig/issues/25067 | 1166 | var res = (try r.takeStructPointer(T)).*; |
| 1167 | // by avoiding a call to `peekStructPointer`. | | |
| 1168 | const struct_bytes = try r.takeArray(@sizeOf(T)); | | |
| 1169 | var res: T = undefined; | | |
| 1170 | @memcpy(@as([]u8, @ptrCast(&res)), struct_bytes); | | |
| 1171 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); | 1167 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1172 | return res; | 1168 | return res; |
| 1173 | }, | 1169 | }, |
| ... | @@ -1192,11 +1188,7 @@ pub inline fn peekStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia | ... | @@ -1192,11 +1188,7 @@ pub inline fn peekStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1192 | .@"struct" => |info| switch (info.layout) { | 1188 | .@"struct" => |info| switch (info.layout) { |
| 1193 | .auto => @compileError("ill-defined memory layout"), | 1189 | .auto => @compileError("ill-defined memory layout"), |
| 1194 | .@"extern" => { | 1190 | .@"extern" => { |
| 1195 | // This code works around https://github.com/ziglang/zig/issues/25067 | 1191 | var res = (try r.peekStructPointer(T)).*; |
| 1196 | // by avoiding a call to `peekStructPointer`. | | |
| 1197 | const struct_bytes = try r.peekArray(@sizeOf(T)); | | |
| 1198 | var res: T = undefined; | | |
| 1199 | @memcpy(@as([]u8, @ptrCast(&res)), struct_bytes); | | |
| 1200 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); | 1192 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1201 | return res; | 1193 | return res; |
| 1202 | }, | 1194 | }, |