| ... | ... | @@ -1163,7 +1163,11 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1163 | 1163 | .@"struct" => |info| switch (info.layout) { |
| 1164 | 1164 | .auto => @compileError("ill-defined memory layout"), |
| 1165 | 1165 | .@"extern" => { |
| 1166 | | var res = (try r.takeStructPointer(T)).*; |
| 1166 | // This code works around https://github.com/ziglang/zig/issues/25067 |
| 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); |
| 1167 | 1171 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1168 | 1172 | return res; |
| 1169 | 1173 | }, |
| ... | ... | @@ -1188,7 +1192,11 @@ pub inline fn peekStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1188 | 1192 | .@"struct" => |info| switch (info.layout) { |
| 1189 | 1193 | .auto => @compileError("ill-defined memory layout"), |
| 1190 | 1194 | .@"extern" => { |
| 1191 | | var res = (try r.peekStructPointer(T)).*; |
| 1195 | // This code works around https://github.com/ziglang/zig/issues/25067 |
| 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); |
| 1192 | 1200 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1193 | 1201 | return res; |
| 1194 | 1202 | }, |