| ... | ... | @@ -124,9 +124,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header { |
| 124 | 124 | const buf = fifo.readableSlice(0); |
| 125 | 125 | assert(fifo.readableLength() == buf.len); |
| 126 | 126 | if (buf.len >= @sizeOf(Header)) { |
| 127 | | // workaround for https://github.com/ziglang/zig/issues/14904 |
| 128 | | const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]); |
| 129 | | const tag = bswap_and_workaround_tag(buf[0..][0..4]); |
| 127 | const header: *align(1) const Header = @ptrCast(buf[0..@sizeOf(Header)]); |
| 128 | const bytes_len = bswap(header.bytes_len); |
| 129 | const tag = bswap(header.tag); |
| 130 | 130 | |
| 131 | 131 | if (buf.len - @sizeOf(Header) >= bytes_len) { |
| 132 | 132 | fifo.discard(@sizeOf(Header)); |
| ... | ... | @@ -307,17 +307,6 @@ fn bswap_u32_array(slice: []u32) void { |
| 307 | 307 | for (slice) |*elem| elem.* = @byteSwap(elem.*); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | | /// workaround for https://github.com/ziglang/zig/issues/14904 |
| 311 | | fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 { |
| 312 | | return std.mem.readInt(u32, bytes_ptr, .little); |
| 313 | | } |
| 314 | | |
| 315 | | /// workaround for https://github.com/ziglang/zig/issues/14904 |
| 316 | | fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag { |
| 317 | | const int = std.mem.readInt(u32, bytes_ptr, .little); |
| 318 | | return @as(InMessage.Tag, @enumFromInt(int)); |
| 319 | | } |
| 320 | | |
| 321 | 310 | const OutMessage = std.zig.Server.Message; |
| 322 | 311 | const InMessage = std.zig.Client.Message; |
| 323 | 312 | |