authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-04 20:35:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-06 22:42:42-07:00
logfe0ff7f718182a023a39c6126f40e5ffe3364f7b
treeafc74c73b531d268fc5c89348649d5f756a42000
parent18c4a500b6fd93e3e48ccaf413f2e9f90730f069

fix 32-bit builds


3 files changed, 33 insertions(+), 33 deletions(-)

lib/std/crypto/tls/Client.zig+2-2
...@@ -910,7 +910,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client...@@ -910,7 +910,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
910}910}
911911
912fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {912fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {
913 const c: *Client = @fieldParentPtr("writer", w);913 const c: *Client = @alignCast(@fieldParentPtr("writer", w));
914 if (true) @panic("update to use the buffer and flush");914 if (true) @panic("update to use the buffer and flush");
915 const sliced_data = if (splat == 0) data[0..data.len -| 1] else data;915 const sliced_data = if (splat == 0) data[0..data.len -| 1] else data;
916 const output = c.output;916 const output = c.output;
...@@ -1046,7 +1046,7 @@ pub fn eof(c: Client) bool {...@@ -1046,7 +1046,7 @@ pub fn eof(c: Client) bool {
1046}1046}
10471047
1048fn stream(r: *Reader, w: *Writer, limit: std.io.Limit) Reader.StreamError!usize {1048fn stream(r: *Reader, w: *Writer, limit: std.io.Limit) Reader.StreamError!usize {
1049 const c: *Client = @fieldParentPtr("reader", r);1049 const c: *Client = @alignCast(@fieldParentPtr("reader", r));
1050 if (c.eof()) return error.EndOfStream;1050 if (c.eof()) return error.EndOfStream;
1051 const input = c.input;1051 const input = c.input;
1052 // If at least one full encrypted record is not buffered, read once.1052 // If at least one full encrypted record is not buffered, read once.
lib/std/http.zig+19-19
...@@ -519,33 +519,33 @@ pub const Reader = struct {...@@ -519,33 +519,33 @@ pub const Reader = struct {
519 w: *Writer,519 w: *Writer,
520 limit: std.Io.Limit,520 limit: std.Io.Limit,
521 ) std.Io.Reader.StreamError!usize {521 ) std.Io.Reader.StreamError!usize {
522 const reader: *Reader = @fieldParentPtr("interface", io_r);522 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
523 const remaining_content_length = &reader.state.body_remaining_content_length;523 const remaining_content_length = &reader.state.body_remaining_content_length;
524 const remaining = remaining_content_length.*;524 const remaining = remaining_content_length.*;
525 if (remaining == 0) {525 if (remaining == 0) {
526 reader.state = .ready;526 reader.state = .ready;
527 return error.EndOfStream;527 return error.EndOfStream;
528 }528 }
529 const n = try reader.in.stream(w, limit.min(.limited(remaining)));529 const n = try reader.in.stream(w, limit.min(.limited64(remaining)));
530 remaining_content_length.* = remaining - n;530 remaining_content_length.* = remaining - n;
531 return n;531 return n;
532 }532 }
533533
534 fn contentLengthDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {534 fn contentLengthDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {
535 const reader: *Reader = @fieldParentPtr("interface", io_r);535 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
536 const remaining_content_length = &reader.state.body_remaining_content_length;536 const remaining_content_length = &reader.state.body_remaining_content_length;
537 const remaining = remaining_content_length.*;537 const remaining = remaining_content_length.*;
538 if (remaining == 0) {538 if (remaining == 0) {
539 reader.state = .ready;539 reader.state = .ready;
540 return error.EndOfStream;540 return error.EndOfStream;
541 }541 }
542 const n = try reader.in.discard(limit.min(.limited(remaining)));542 const n = try reader.in.discard(limit.min(.limited64(remaining)));
543 remaining_content_length.* = remaining - n;543 remaining_content_length.* = remaining - n;
544 return n;544 return n;
545 }545 }
546546
547 fn chunkedStream(io_r: *std.Io.Reader, w: *Writer, limit: std.Io.Limit) std.Io.Reader.StreamError!usize {547 fn chunkedStream(io_r: *std.Io.Reader, w: *Writer, limit: std.Io.Limit) std.Io.Reader.StreamError!usize {
548 const reader: *Reader = @fieldParentPtr("interface", io_r);548 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
549 const chunk_len_ptr = switch (reader.state) {549 const chunk_len_ptr = switch (reader.state) {
550 .ready => return error.EndOfStream,550 .ready => return error.EndOfStream,
551 .body_remaining_chunk_len => |*x| x,551 .body_remaining_chunk_len => |*x| x,
...@@ -591,7 +591,7 @@ pub const Reader = struct {...@@ -591,7 +591,7 @@ pub const Reader = struct {
591 }591 }
592 }592 }
593 if (cp.chunk_len == 0) return parseTrailers(reader, 0);593 if (cp.chunk_len == 0) return parseTrailers(reader, 0);
594 const n = try in.stream(w, limit.min(.limited(cp.chunk_len)));594 const n = try in.stream(w, limit.min(.limited64(cp.chunk_len)));
595 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);595 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);
596 return n;596 return n;
597 },597 },
...@@ -607,7 +607,7 @@ pub const Reader = struct {...@@ -607,7 +607,7 @@ pub const Reader = struct {
607 continue :len .head;607 continue :len .head;
608 },608 },
609 else => |remaining_chunk_len| {609 else => |remaining_chunk_len| {
610 const n = try in.stream(w, limit.min(.limited(@intFromEnum(remaining_chunk_len) - 2)));610 const n = try in.stream(w, limit.min(.limited64(@intFromEnum(remaining_chunk_len) - 2)));
611 chunk_len_ptr.* = .init(@intFromEnum(remaining_chunk_len) - n);611 chunk_len_ptr.* = .init(@intFromEnum(remaining_chunk_len) - n);
612 return n;612 return n;
613 },613 },
...@@ -615,7 +615,7 @@ pub const Reader = struct {...@@ -615,7 +615,7 @@ pub const Reader = struct {
615 }615 }
616616
617 fn chunkedDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {617 fn chunkedDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {
618 const reader: *Reader = @fieldParentPtr("interface", io_r);618 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
619 const chunk_len_ptr = switch (reader.state) {619 const chunk_len_ptr = switch (reader.state) {
620 .ready => return error.EndOfStream,620 .ready => return error.EndOfStream,
621 .body_remaining_chunk_len => |*x| x,621 .body_remaining_chunk_len => |*x| x,
...@@ -659,7 +659,7 @@ pub const Reader = struct {...@@ -659,7 +659,7 @@ pub const Reader = struct {
659 }659 }
660 }660 }
661 if (cp.chunk_len == 0) return parseTrailers(reader, 0);661 if (cp.chunk_len == 0) return parseTrailers(reader, 0);
662 const n = try in.discard(limit.min(.limited(cp.chunk_len)));662 const n = try in.discard(limit.min(.limited64(cp.chunk_len)));
663 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);663 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);
664 return n;664 return n;
665 },665 },
...@@ -675,7 +675,7 @@ pub const Reader = struct {...@@ -675,7 +675,7 @@ pub const Reader = struct {
675 continue :len .head;675 continue :len .head;
676 },676 },
677 else => |remaining_chunk_len| {677 else => |remaining_chunk_len| {
678 const n = try in.discard(limit.min(.limited(remaining_chunk_len.int() - 2)));678 const n = try in.discard(limit.min(.limited64(remaining_chunk_len.int() - 2)));
679 chunk_len_ptr.* = .init(remaining_chunk_len.int() - n);679 chunk_len_ptr.* = .init(remaining_chunk_len.int() - n);
680 return n;680 return n;
681 },681 },
...@@ -758,7 +758,7 @@ pub const BodyWriter = struct {...@@ -758,7 +758,7 @@ pub const BodyWriter = struct {
758758
759 /// How many zeroes to reserve for hex-encoded chunk length.759 /// How many zeroes to reserve for hex-encoded chunk length.
760 const chunk_len_digits = 8;760 const chunk_len_digits = 8;
761 const max_chunk_len: usize = std.math.pow(usize, 16, chunk_len_digits) - 1;761 const max_chunk_len: usize = std.math.pow(u64, 16, chunk_len_digits) - 1;
762 const chunk_header_template = ("0" ** chunk_len_digits) ++ "\r\n";762 const chunk_header_template = ("0" ** chunk_len_digits) ++ "\r\n";
763763
764 comptime {764 comptime {
...@@ -918,7 +918,7 @@ pub const BodyWriter = struct {...@@ -918,7 +918,7 @@ pub const BodyWriter = struct {
918 }918 }
919919
920 pub fn contentLengthDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {920 pub fn contentLengthDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
921 const bw: *BodyWriter = @fieldParentPtr("writer", w);921 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
922 assert(!bw.isEliding());922 assert(!bw.isEliding());
923 const out = bw.http_protocol_output;923 const out = bw.http_protocol_output;
924 const n = try out.writeSplatHeader(w.buffered(), data, splat);924 const n = try out.writeSplatHeader(w.buffered(), data, splat);
...@@ -927,7 +927,7 @@ pub const BodyWriter = struct {...@@ -927,7 +927,7 @@ pub const BodyWriter = struct {
927 }927 }
928928
929 pub fn noneDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {929 pub fn noneDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
930 const bw: *BodyWriter = @fieldParentPtr("writer", w);930 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
931 assert(!bw.isEliding());931 assert(!bw.isEliding());
932 const out = bw.http_protocol_output;932 const out = bw.http_protocol_output;
933 const n = try out.writeSplatHeader(w.buffered(), data, splat);933 const n = try out.writeSplatHeader(w.buffered(), data, splat);
...@@ -935,7 +935,7 @@ pub const BodyWriter = struct {...@@ -935,7 +935,7 @@ pub const BodyWriter = struct {
935 }935 }
936936
937 pub fn elidingDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {937 pub fn elidingDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
938 const bw: *BodyWriter = @fieldParentPtr("writer", w);938 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
939 const slice = data[0 .. data.len - 1];939 const slice = data[0 .. data.len - 1];
940 const pattern = data[slice.len];940 const pattern = data[slice.len];
941 var written: usize = pattern.len * splat;941 var written: usize = pattern.len * splat;
...@@ -949,7 +949,7 @@ pub const BodyWriter = struct {...@@ -949,7 +949,7 @@ pub const BodyWriter = struct {
949 }949 }
950950
951 pub fn elidingSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {951 pub fn elidingSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
952 const bw: *BodyWriter = @fieldParentPtr("writer", w);952 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
953 if (File.Handle == void) return error.Unimplemented;953 if (File.Handle == void) return error.Unimplemented;
954 if (builtin.zig_backend == .stage2_aarch64) return error.Unimplemented;954 if (builtin.zig_backend == .stage2_aarch64) return error.Unimplemented;
955 switch (bw.state) {955 switch (bw.state) {
...@@ -976,7 +976,7 @@ pub const BodyWriter = struct {...@@ -976,7 +976,7 @@ pub const BodyWriter = struct {
976976
977 /// Returns `null` if size cannot be computed without making any syscalls.977 /// Returns `null` if size cannot be computed without making any syscalls.
978 pub fn noneSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {978 pub fn noneSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
979 const bw: *BodyWriter = @fieldParentPtr("writer", w);979 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
980 assert(!bw.isEliding());980 assert(!bw.isEliding());
981 const out = bw.http_protocol_output;981 const out = bw.http_protocol_output;
982 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);982 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);
...@@ -984,7 +984,7 @@ pub const BodyWriter = struct {...@@ -984,7 +984,7 @@ pub const BodyWriter = struct {
984 }984 }
985985
986 pub fn contentLengthSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {986 pub fn contentLengthSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
987 const bw: *BodyWriter = @fieldParentPtr("writer", w);987 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
988 assert(!bw.isEliding());988 assert(!bw.isEliding());
989 const out = bw.http_protocol_output;989 const out = bw.http_protocol_output;
990 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);990 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);
...@@ -993,7 +993,7 @@ pub const BodyWriter = struct {...@@ -993,7 +993,7 @@ pub const BodyWriter = struct {
993 }993 }
994994
995 pub fn chunkedSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {995 pub fn chunkedSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
996 const bw: *BodyWriter = @fieldParentPtr("writer", w);996 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
997 assert(!bw.isEliding());997 assert(!bw.isEliding());
998 const data_len = Writer.countSendFileLowerBound(w.end, file_reader, limit) orelse {998 const data_len = Writer.countSendFileLowerBound(w.end, file_reader, limit) orelse {
999 // If the file size is unknown, we cannot lower to a `sendFile` since we would999 // If the file size is unknown, we cannot lower to a `sendFile` since we would
...@@ -1041,7 +1041,7 @@ pub const BodyWriter = struct {...@@ -1041,7 +1041,7 @@ pub const BodyWriter = struct {
1041 }1041 }
10421042
1043 pub fn chunkedDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {1043 pub fn chunkedDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
1044 const bw: *BodyWriter = @fieldParentPtr("writer", w);1044 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
1045 assert(!bw.isEliding());1045 assert(!bw.isEliding());
1046 const out = bw.http_protocol_output;1046 const out = bw.http_protocol_output;
1047 const data_len = w.end + Writer.countSplat(data, splat);1047 const data_len = w.end + Writer.countSplat(data, splat);
lib/std/http/Client.zig+12-12
...@@ -82,7 +82,7 @@ pub const ConnectionPool = struct {...@@ -82,7 +82,7 @@ pub const ConnectionPool = struct {
8282
83 var next = pool.free.last;83 var next = pool.free.last;
84 while (next) |node| : (next = node.prev) {84 while (next) |node| : (next = node.prev) {
85 const connection: *Connection = @fieldParentPtr("pool_node", node);85 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
86 if (connection.protocol != criteria.protocol) continue;86 if (connection.protocol != criteria.protocol) continue;
87 if (connection.port != criteria.port) continue;87 if (connection.port != criteria.port) continue;
8888
...@@ -127,7 +127,7 @@ pub const ConnectionPool = struct {...@@ -127,7 +127,7 @@ pub const ConnectionPool = struct {
127 if (connection.closing or pool.free_size == 0) return connection.destroy();127 if (connection.closing or pool.free_size == 0) return connection.destroy();
128128
129 if (pool.free_len >= pool.free_size) {129 if (pool.free_len >= pool.free_size) {
130 const popped: *Connection = @fieldParentPtr("pool_node", pool.free.popFirst().?);130 const popped: *Connection = @alignCast(@fieldParentPtr("pool_node", pool.free.popFirst().?));
131 pool.free_len -= 1;131 pool.free_len -= 1;
132132
133 popped.destroy();133 popped.destroy();
...@@ -183,14 +183,14 @@ pub const ConnectionPool = struct {...@@ -183,14 +183,14 @@ pub const ConnectionPool = struct {
183183
184 var next = pool.free.first;184 var next = pool.free.first;
185 while (next) |node| {185 while (next) |node| {
186 const connection: *Connection = @fieldParentPtr("pool_node", node);186 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
187 next = node.next;187 next = node.next;
188 connection.destroy();188 connection.destroy();
189 }189 }
190190
191 next = pool.used.first;191 next = pool.used.first;
192 while (next) |node| {192 while (next) |node| {
193 const connection: *Connection = @fieldParentPtr("pool_node", node);193 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
194 next = node.next;194 next = node.next;
195 connection.destroy();195 connection.destroy();
196 }196 }
...@@ -366,11 +366,11 @@ pub const Connection = struct {...@@ -366,11 +366,11 @@ pub const Connection = struct {
366 return switch (c.protocol) {366 return switch (c.protocol) {
367 .tls => {367 .tls => {
368 if (disable_tls) unreachable;368 if (disable_tls) unreachable;
369 const tls: *Tls = @fieldParentPtr("connection", c);369 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
370 return tls.host();370 return tls.host();
371 },371 },
372 .plain => {372 .plain => {
373 const plain: *Plain = @fieldParentPtr("connection", c);373 const plain: *Plain = @alignCast(@fieldParentPtr("connection", c));
374 return plain.host();374 return plain.host();
375 },375 },
376 };376 };
...@@ -383,11 +383,11 @@ pub const Connection = struct {...@@ -383,11 +383,11 @@ pub const Connection = struct {
383 switch (c.protocol) {383 switch (c.protocol) {
384 .tls => {384 .tls => {
385 if (disable_tls) unreachable;385 if (disable_tls) unreachable;
386 const tls: *Tls = @fieldParentPtr("connection", c);386 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
387 tls.destroy();387 tls.destroy();
388 },388 },
389 .plain => {389 .plain => {
390 const plain: *Plain = @fieldParentPtr("connection", c);390 const plain: *Plain = @alignCast(@fieldParentPtr("connection", c));
391 plain.destroy();391 plain.destroy();
392 },392 },
393 }393 }
...@@ -399,7 +399,7 @@ pub const Connection = struct {...@@ -399,7 +399,7 @@ pub const Connection = struct {
399 return switch (c.protocol) {399 return switch (c.protocol) {
400 .tls => {400 .tls => {
401 if (disable_tls) unreachable;401 if (disable_tls) unreachable;
402 const tls: *Tls = @fieldParentPtr("connection", c);402 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
403 return &tls.client.writer;403 return &tls.client.writer;
404 },404 },
405 .plain => &c.stream_writer.interface,405 .plain => &c.stream_writer.interface,
...@@ -412,7 +412,7 @@ pub const Connection = struct {...@@ -412,7 +412,7 @@ pub const Connection = struct {
412 return switch (c.protocol) {412 return switch (c.protocol) {
413 .tls => {413 .tls => {
414 if (disable_tls) unreachable;414 if (disable_tls) unreachable;
415 const tls: *Tls = @fieldParentPtr("connection", c);415 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
416 return &tls.client.reader;416 return &tls.client.reader;
417 },417 },
418 .plain => c.stream_reader.interface(),418 .plain => c.stream_reader.interface(),
...@@ -422,7 +422,7 @@ pub const Connection = struct {...@@ -422,7 +422,7 @@ pub const Connection = struct {
422 pub fn flush(c: *Connection) Writer.Error!void {422 pub fn flush(c: *Connection) Writer.Error!void {
423 if (c.protocol == .tls) {423 if (c.protocol == .tls) {
424 if (disable_tls) unreachable;424 if (disable_tls) unreachable;
425 const tls: *Tls = @fieldParentPtr("connection", c);425 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
426 try tls.client.writer.flush();426 try tls.client.writer.flush();
427 }427 }
428 try c.stream_writer.interface.flush();428 try c.stream_writer.interface.flush();
...@@ -434,7 +434,7 @@ pub const Connection = struct {...@@ -434,7 +434,7 @@ pub const Connection = struct {
434 pub fn end(c: *Connection) Writer.Error!void {434 pub fn end(c: *Connection) Writer.Error!void {
435 if (c.protocol == .tls) {435 if (c.protocol == .tls) {
436 if (disable_tls) unreachable;436 if (disable_tls) unreachable;
437 const tls: *Tls = @fieldParentPtr("connection", c);437 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
438 try tls.client.end();438 try tls.client.end();
439 try tls.client.writer.flush();439 try tls.client.writer.flush();
440 }440 }