| ... | @@ -1163,7 +1163,11 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia | ... | @@ -1163,7 +1163,11 @@ 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 | 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 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); | 1171 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1168 | return res; | 1172 | return res; |
| 1169 | }, | 1173 | }, |
| ... | @@ -1188,7 +1192,11 @@ pub inline fn peekStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia | ... | @@ -1188,7 +1192,11 @@ pub inline fn peekStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1188 | .@"struct" => |info| switch (info.layout) { | 1192 | .@"struct" => |info| switch (info.layout) { |
| 1189 | .auto => @compileError("ill-defined memory layout"), | 1193 | .auto => @compileError("ill-defined memory layout"), |
| 1190 | .@"extern" => { | 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 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); | 1200 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1193 | return res; | 1201 | return res; |
| 1194 | }, | 1202 | }, |